__cdecl callback function with P/Invoke

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 ;)
 
C

Chris Taylor

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top