How to setup a CDECL callback to C# Delagate

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Win32 DLL that has a standard _stdcall (WINAPI) exports. I am able
to call these fine from C#. One call in particular however has a callback to
a CDECL function. How would I set that up? Following is the specific.

Win32 DLL Declaration for function in MyDLL.dll
extern "C" int WINAPI SpecialTimerFunction(int Val, int (*Callback)(int
InVal))

C# Declaration
public class MyClass
{
public delegate int MyCallback(int InVal);

[DllImport("MyDLL.dll")]
public static extern int SpecialTimerFunction(int Val,MyCallback Callback);
}

How do I declare the delegate to ensure that the marshaller will understand
that the callback is of type CDECL?

Thanks a million.
Berto
 
How do I declare the delegate to ensure that the marshaller will understand
that the callback is of type CDECL?

There's no way to do that in C# v1.x.



Mattias
 
Back
Top