How to setup a CDECL callback to C# Delagate

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
 
M

Mattias Sjögren

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
 

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