Put a breakpoint on the SetupDiCreateDeviceInfoList() statement and single-step through the code until you get to the statement that causes the error. I cleaned up your code a bit to look like:
HDEVINFO DoDeviceEnum( void )
{
GUID InterfaceClassGuid;
HDEVINFO DeviceInfoSet,
NewDeviceInfoSet;
DeviceInfoSet = SetupDiCreateDeviceInfoList(&InterfaceClassGuid, NULL);
if (DeviceInfoSet != INVALID\_HANDLE\_VALUE)
{
NewDeviceInfoSet = SetupDiGetClassDevsEx(&InterfaceClassGuid,
NULL,
NULL,
DIGCF\_PRESENT | DIGCF\_DEVICEINTERFACE,
DeviceInfoSet,
NULL,
NULL);
if (NewDeviceInfoSet != INVALID\_HANDLE\_VALUE)
; // do something with the list
else
printf("SetupDiGetClassDevsEx failed: %lu.\\n", GetLastError());
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
}
else
printf("SetupDiCreateDeviceInfoList failed: %lu.\\n", GetLastError());
return NewDeviceInfoSet;
}
void main( void )
{
DoDeviceEnum();
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow