A
anonymous
Is there an easy way to convert a byte array into an
IntPtr? I want to P-Invoke a function that takes a
structure, which points to a byte array. I'd like to set
the structure pointer to one of my managed Byte arrays.
byte [] mybytes = new byte[400];
// fill in mybytes in managed code
public struct Mine{
int x, y;
IntPtr ByteArray;
}
//I'd like to have:
Mine mn = new Mine(); mn.ByteArray = (ref mybytes[0]);
Setting IntPtr to (Byte []) won't work since C# arrays
have a leading length count, right? Any help would be
appreciated. thanks.
(Is the only way to do a LocalAlloc for the IntPtr and
copy all the data from managed to unmanaged memory?)
IntPtr? I want to P-Invoke a function that takes a
structure, which points to a byte array. I'd like to set
the structure pointer to one of my managed Byte arrays.
byte [] mybytes = new byte[400];
// fill in mybytes in managed code
public struct Mine{
int x, y;
IntPtr ByteArray;
}
//I'd like to have:
Mine mn = new Mine(); mn.ByteArray = (ref mybytes[0]);
Setting IntPtr to (Byte []) won't work since C# arrays
have a leading length count, right? Any help would be
appreciated. thanks.
(Is the only way to do a LocalAlloc for the IntPtr and
copy all the data from managed to unmanaged memory?)