__cdecl callback function with P/Invoke

  • Thread starter Thread starter pawel
  • Start date Start date
P

pawel

Hi!
I have a .dll library, with some exported function, which looks something
like this:

extern "C" {
int exported_f (int (__cdecl *callback) (int a, int b)) ;
}

now, I want to invoke this function wihtin the managed code and supply my
managed delegate function poiter as callback. I use DllImport, we know how
to do this ;)
The problem is that: when the function pointer parameter in exported
function is __stdcall, everythig works just fine. But how can I use
delegates for __cdecl callback function pointers ?..
I found CallingConventions, but this is only valid for imported function
itself, not for its parameters :((
Please, help me ! (sorry for my poor english ;)
 
Hi,

You can not do this in C#/VB.NET. An option might be to write a MC++ wrapper
for the library function and then let the MC++ callback call to your
delegate.

Hope this helps
 
Back
Top