G
Guest
I need to call into a C++ DLL from my C# code.
The function is expecting a void pointer to an unsigned short.
Which would be more correct?
UInt16 wRegData;
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(wRegData));
Marshal.StructureToPtr(wRegData, p, false);
or
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(wRegData));
Marshal.WriteInt16(p, (short) wRegData);
Thank you.
The function is expecting a void pointer to an unsigned short.
Which would be more correct?
UInt16 wRegData;
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(wRegData));
Marshal.StructureToPtr(wRegData, p, false);
or
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(wRegData));
Marshal.WriteInt16(p, (short) wRegData);
Thank you.