STD: : string strClassName="4 d36e972 - e325 ce - bfc1-08002-11 be10318";
TCHAR * GUIDString=NULL;
GUID GUID, guid1;
ZeroMemory (& amp; Guid, sizeof (guid));
ZeroMemory (& amp; Guid1, sizeof (GUID));
GUIDString=(char *) strClassName. C_str ();
UuidFromString ((unsigned char *) GUIDString, & amp; Guid);
HDevInfo=SetupDiGetClassDevs (& amp; Guid, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
If (INVALID_HANDLE_VALUE=hDevInfo https://bbs.csdn.net/topics/=
{
//FormatMSG (GetLastError (), & amp; LpszMsg);
Throw lpszMsg;
}
DWORD I=0;
SP_DEVINFO_DATA DeviceInfoData;
ZeroMemory (& amp; DeviceInfoData, sizeof (SP_DEVINFO_DATA));
DeviceInfoData. CbSize=sizeof (SP_DEVINFO_DATA);
BOOL bSuccess=SetupDiEnumDeviceInfo (hDevInfo, 0, & amp; DeviceInfoData);
DWORD nError=GetLastError ();
Consult expert, for this problem for a long time, we appreciate your guidance,
CodePudding user response:
Problems should be out here DeviceInfoData. CbSize=sizeof (SP_DEVINFO_DATA);If it is a 64 - bit operating system distribution of 32 it
If it is a 32-bit operating system distribution of 28 it
A breakpoint and see if it is 32 bytes?
CodePudding user response:
What the compiler, VS2008, VS2013 didn't this problemCodePudding user response:
Vc6.0 DeviceInfoData cbSize=32 also not line, must change the compilerCodePudding user response:
No import appropriate dynamic link libraries, or does not define the appropriate GUID
#include
#include
# pragma comment (lib, "Winmm. Lib")
# pragma comment (lib, "setupapi. Lib")
//DEFINE_GUID (GUID_DEVINTERFACE_USB_HUB,
X11d0 xc30c xf18a0e88//0, 0, 0, 0 x88, 0 x15, 0 x00 to 0 xa0, 0 xc9, 0 x06, 0 xbe, 0 xd8);
DEFINE_GUID (GUID_DEVINTERFACE_USB_DEVICE,
X11d2 xa5dcbf10l 0, 0 x6530, 0, 0, x90 x1f 0, 0 x00 to 0 xc0, 0 x4f, 0 xb9, 0 x51, 0 xed);
# define GUID_CLASS_USB_DEVICE GUID_DEVINTERFACE_USB_DEVICE
//here call success SetupDiEnumDeviceInfo
//has been testing, win8.1 x64 version can normal enumerated all usb devices
CodePudding user response:
Recommended CxDeviceFind class to find the USB devices and other equipmenthttp://www.cnblogs.com/EdmundDwyane/p/3161524.html