I have a structure
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct SERVER_USB_DEVICE
{
USB_HWID usbHWID;
byte status;
bool bExcludeDevice;
bool bSharedManually;
ulong ulDeviceId;
ulong ulClientAddr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
string usbDeviceDescr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
string locationInfo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
string nickName;
}
When I pass it in a win32 DLL function as below:
[DllImport ("abc.dll", EntryPoint="EnumDevices", CharSet=CharSet.Ansi)]
public static extern bool EnumDevices(IntPtr lpUsbDevices,
ref ulong pulBufferSize,
IntPtr lpES);
I get some missing text in the string members of the structure.
Suppose SERVER_USB_DEVICE.usbDeviceDescr contains value "Mass Storage Device" which is wrong it should contain value "USB Mass Storage Device"
What is wrong in the code?