|
-
January 21st, 2009, 09:18 AM
#1
Get Function Address
Hello All,
I have imported a .dll into my C# project. One of the function in dll is:
extern "C" __declspec(dllexport) void SetCallbackProcAddr(long lProcAddress)
{
g_CallbackProc = (decodePacket)lProcAddress;
}
which takes address of function from client project.
In my client project, I am having :
namespace Client
{
Class useDLL
{
[DllImport("exampleDLL.dll", EntryPoint = "SetCallbackProcAddr", ExactSpelling = false, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern unsafe void SetCallbackProcAddr(long* apPointer);
//And I would like to pass below's function address to above function
public void CallBack(IntPtr apData, int aDataSize)
{
}
//Function test is called from main
public void test()
{
Client.SetCallbackProcAddr(????????); //What should replace ?????????
}
//Has someone any idea how should I pass on address of CallBack function )
}
}
I am new to C# and want first to import my projects in form of dll. example.dll is one of the projects which is using c++ and c files.
Can someone be of help?
Thanks and regards,
Ricky
-
January 22nd, 2009, 06:52 PM
#2
-
January 22nd, 2009, 06:59 PM
#3
Re: Get Function Address
yes delegate is like c++ function pointer
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
-
January 27th, 2009, 03:44 AM
#4
Re: Get Function Address
Thanks Toraj and MadHatter. It is working now.
Am using delegate now and to get memory address I had to use
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void callbackDelegate(in param)
regards,
Ricky
-
January 27th, 2009, 04:16 AM
#5
Re: Get Function Address
Ricky, please use CODE tags in future, when you post code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|