You did not tell us the problem. But with
SetupDiEnumDeviceInfo()
, you must check the return value and call
GetLastError()
to detect when no more items are available:
BOOL bResult = TRUE; while (bResult)
{
bResult = SetupDiEnumDeviceInfo(devs, devIndex++, &devInfo);
if (!bResult)
{
if (ERROR_NO_MORE_ITEMS == GetLastError())
bResult = TRUE;
break;
}
}
To check for specific device types, you must pass a GUID to
SetupDiGetClassDevs()
:
const GUID GUID_DEVINTERFACE_IMAGING = {
0x6bdd1fc6, 0x810f, 0x11d0, { 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f }
};
devs = SetupDiGetClassDevs(&GUID_DEVINTERFACE_IMAGING, 0, 0, DIGCF_PRESENT | DIGCF_INTERFACE | DIGCF_PROFILE );
See
System-Defined Device Setup Classes Available[
^] in the MSDN for GUIDs.