gongdehui

gongdehui

  • NA
  • 63
  • 0

Why SetupDiEnumDeviceInterfaces() always returns false?

Nov 2 2004 8:22 AM
//my c# code: public class Win32 {...... public static Guid GUID_DEVINTERFACE_USB_DEVICE = new Guid("A5DCBF10-6530-11D2-901F-00C04FB951ED"); public class SP_DEVICE_INTERFACE_DATA { public int cbSize; public Guid InterfaceClassGuid; public int Flags; public ulong Reserved; } ...... } public class usbdevice { IntPtr hDevInfo; Win32.SP_DEVICE_INTERFACE_DATA DeviceInterfaceData = new Win32.SP_DEVICE_INTERFACE_DATA(); ...... hDevInfo = Win32.SetupDiGetClassDevs(ref Win32.GUID_DEVINTERFACE_USB_DEVICE, null, // Enumerator null, Win32.DIGCF_PRESENT | Win32.DIGCF_DEVICEINTERFACE); //flags ...... DeviceInterfaceData.cbSize = (int)Marshal.SizeOf(new Win32.SP_DEVICE_INTERFACE_DATA().GetType()); bResult = SetupDiEnumDeviceInterfaces(hDevInfo, null, ref Win32.GUID_DEVINTERFACE_USB_DEVICE, memberIndex, DeviceInterfaceData); ...... } //after invoked the Win32.SetupDiGetClassDevs(),the hDevInfo is not -1. But the bResult always returns false,what's the problem? Thanks!

Answers (1)