gongdehui

gongdehui

  • NA
  • 63
  • 0

Error 1784 when invoke SetupDiGetDeviceInterfaceDetail() in C#

Nov 7 2004 9:44 AM
//c# code: public class Win32 {...... [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct SP_DEVICE_INTERFACE_DETAIL_DATA { public uint cbSize; public char* DevicePath; } [DllImport("setupapi.dll", CharSet=CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupDiGetDeviceInterfaceDetail( [In]IntPtr DeviceInfoSet, [In] SP_DEVICE_INTERFACE_DATA *DeviceInterfaceData, [Out]SP_DEVICE_INTERFACE_DETAIL_DATA *DeviceInterfaceDetailData, [In]int DeviceInterfaceDetailDataSize, [Out]int *RequiredSize, [Out]SP_DEVINFO_DATA *DeviceInfoData ); ...... } public class usbdevice {...... ptrDeviceInterfaceDetailData = (Win32.SP_DEVICE_INTERFACE_DETAIL_DATA*)Win32.GlobalAlloc(Win32.GPTR,nBytesRequired); ptrDeviceInterfaceDetailData->cbSize = (uint)sizeof(Win32.SP_DEVICE_INTERFACE_DETAIL_DATA); ptrDeviceInfoData->cbSize = Marshal.SizeOf( new Win32.SP_DEVINFO_DATA().GetType() ); bResult =Win32.SetupDiGetDeviceInterfaceDetail(hDevInfo, ptrDeviceInterfaceData, ptrDeviceInterfaceDetailData, //[out] pointer to a buffer to store the interface detail data nBytesRequired, // the buffer size null, ptrDeviceInfoData); lasterror = Win32.GetLastError();// Error number:1784. How to settle this problem????

Answers (4)