Problem with method signatures and P/Invoke

T

t4urean

I am involved in a project whereby I have to use a methods from a Win32 dll.
There are two methods for which I can't write signature in C#

I have even tried using p/invoke wizard, but it didn't gave the right answer.

The C/C++ declaration for these methods is

BOOL __stdcall CodecStart(int hRadio,void __stdcall (*CallbackFunc)(void *),
void *CallbackTarget);
and

DWORD __stdcall CodecRead(int hRadio, void *Buf, DWORD Size);

I would highly appreciate if any2 can suggest the signature that I can use in
C#
 
M

Mattias Sjögren

BOOL __stdcall CodecStart(int hRadio,void __stdcall (*CallbackFunc)(void *),
void *CallbackTarget);
and

DWORD __stdcall CodecRead(int hRadio, void *Buf, DWORD Size);

I would highly appreciate if any2 can suggest the signature that I can use in
C#

delegate void CallbackFunc(IntPtr p);

static extern bool CodecStart(int hRadio, CallbackFunc func, IntPtr
CallbackTarget);

static extern uint CodecRead(int hRadio, byte[] Buf, uint Size);

You can adjust the type of the Buf parameter to a certain degree to
fit the type of data you'll actually read.


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