Possible Duplicate:
unsigned char ** equivalent in c# and have to write the return value in a file
I have to call a win32 dll function
int func1(int arg1, unsigned char *arg2, int *arg3);
and i wrote wrapped c# as
public extern int fuc1(int arg1, out IntPtr arg2, out IntPtr arg3);
The arg2 has to allocate 2048 bytes and send it to the win32 dll. I’ll get arg2 and arg3 as output.
how can i declare in c# test application as well as c# wrapper. am i doing it right ?
byte in C# is unsigned 8-bit int. byte[] is an array of them. To get a pointer to this array, use:
or:
Alternatively, if the called function will not cache a pointer to the array, you can simply do this:
P/Invoke will pin it automatically.
MSDN Marshaling Arrays of Types
Related SO question