S
SeC
Hello.
I have external DLL with function:
extern "C" __declspec(dllexport)
void ByteTest(BYTE **arr, BYTE w, BYTE h)
{
BYTE tmp = 0;
for(int i=0; i<h; i++)
{
for(int j=0; j<w; j++)
{
arr[j] = ++tmp;
}
}
}
Now in C#:
[DllImport("test.dll")]
extern static void ByteTest(ref IntPtr ptr, int w, int h);
and
byte[,] tab = new byte[2, 2];
unsafe
{
fixed (void* fptr = tab)
{
IntPtr ptr = new IntPtr(fptr);
ByteTest(ref ptr, 2, 2);
}
}
This works, but I have error values in tab(3, 4, 0, 0) instead of (1,
2, 3, 4). How to marshall BYTE** in C# ?
I have external DLL with function:
extern "C" __declspec(dllexport)
void ByteTest(BYTE **arr, BYTE w, BYTE h)
{
BYTE tmp = 0;
for(int i=0; i<h; i++)
{
for(int j=0; j<w; j++)
{
arr[j] = ++tmp;
}
}
}
Now in C#:
[DllImport("test.dll")]
extern static void ByteTest(ref IntPtr ptr, int w, int h);
and
byte[,] tab = new byte[2, 2];
unsafe
{
fixed (void* fptr = tab)
{
IntPtr ptr = new IntPtr(fptr);
ByteTest(ref ptr, 2, 2);
}
}
This works, but I have error values in tab(3, 4, 0, 0) instead of (1,
2, 3, 4). How to marshall BYTE** in C# ?