farming

Hi,

My keyboard, mouse, and camera, are all connected to my computer by USB interface. However, it shows no USB devices when I use function "SetupDiEnumDeviceInterfaces()". My code is listed as following:

//look up devide of HID
HDEVINFO hDevInfo = SetupDiGetClassDevs(&guidHID,NULL,0,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);

//look up interface of USB
SP_DEVICE_INTERFACE_DATA strtInterfaceData;
BOOL bSuccess = SetupDiEnumDeviceInterfaces(hDevInfo,NULL,&guidHID,0,
&strtInterfaceData);
//the bSuccess is 0 in my result

How can I do Thanks.


Re: Visual C++ General Why I can not find USB device when using function "SetupDiEnumDeviceInterfaces()"

Bite Qiu - MSFT

If you specify a incorrect GUID, the function call will fail, you can use getlasterror() to get more information for the reason it fails. Please also take a example that works correctly as a compare to your code, here I found one for you: http://www.codeguru.com/forum/archive/index.php/t-331907.html

Hope it makes sense

Regards,

Rico






Re: Visual C++ General Why I can not find USB device when using function "SetupDiEnumDeviceInterfaces()"

Chirag

hello farming,
U might only try with the flag DIGCF_PRESENT. this might help u in getting the details of all the currently USB attachments...

Above all other was is there. DIGCF_ALLCLASSES, but u know this will result into every Classes details, so filtering would be difficult... or might be not a correct approach.

regards,
Chirag