I'm not sure what I'm missing but it's time to ask from more knowledgeable people than I. I'm using the HDC GUID that I found here. I'm trying to open with this in my C++ code:
// note: devGuid is pointer of type struct GUID in the class this ctor belongs to
DeviceHelper::DeviceManager::DeviceManager(GUID devClassGuid) : devGuid(new GUID(devClassGuid)) {
hDevices = SetupDiGetClassDevs(&devClassGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if(INVALID_HANDLE_VALUE == hDevices) {
throw std::exception("Failure to get a handle to a list of device classes");
}
}
This call passes and hDevices holds a valid reference. However, when I call SetupDiEnumDeviceInterfaces() it iterates over nothing:
// hDevices is assigned in the c-tor as is devGuid which is a pointer
DWORD index(0);
SP_DEVICE_INTERFACE_DATA devInterfaceData = {sizeof(SP_DEVICE_INTERFACE_DATA)};
while(SetupDiEnumDeviceInterfaces(hDevices, NULL, devGuid, index, &devInterfaceData)) {
// look for the HBA I want from parameters passed to the class function
// FindHba()
}
SetupDiEnumDeviceInterfaces() sets the system error code to 249 which is "no more items" but nothing has been iterated. Apparently, the handle points to an empty list. What is it I'm getting wrong on the call to SetupDiGetClassDevs()? I thought that it might be the GUID isn't an "interface" GUID (i.e. the word "interface" isn't in the name). So, I tried taking off the bitwise-or with DIGCF_DEVICEINTERFACE, but this didn't help.
My knowledge of how to make use of this API is quite limited and I'm doing nothing now but spinning my wheels.
Thanks for any help.