Вы можете получить много информации, используя Модель свойств унифицированного устройства , доступную в Vista и выше.Он имеет свойства DEVPKEY_Device_Class и DEVPKEY_Device_ClassGuid :
HDEVINFO list = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT | DIGCF_ALLCLASSES /*| DIGCF_PROFILE*/);
for (int i = 0; true; ++i)
{
SP_DEVINFO_DATA data = { 0 };
data.cbSize = sizeof(SP_DEVINFO_DATA);
if (!SetupDiEnumDeviceInfo(list, i, &data))
break;
// get name property
DEVPROPTYPE type;
DWORD size = 0;
SetupDiGetDeviceProperty(list, &data, &DEVPKEY_NAME, &type, NULL, 0, &size, 0);
if (size > 0)
{
LPWSTR name = (LPWSTR)malloc(size);
SetupDiGetDeviceProperty(list, &data, &DEVPKEY_NAME, &type, (PBYTE)name, size, &size, 0);
wprintf(L"name: %s\n", name);
free(name);
}
// get class name
SetupDiGetDeviceProperty(list, &data, &DEVPKEY_Device_Class, &type, NULL, 0, &size, 0);
if (size > 0)
{
LPWSTR name = (LPWSTR)malloc(size);
SetupDiGetDeviceProperty(list, &data, &DEVPKEY_Device_Class, &type, (PBYTE)name, size, &size, 0);
wprintf(L" class: %s\n", name);
free(name);
}
// get class guid
SetupDiGetDeviceProperty(list, &data, &DEVPKEY_Device_ClassGuid, &type, NULL, 0, &size, 0);
if (size > 0)
{
GUID* guid = (GUID*)malloc(size);
SetupDiGetDeviceProperty(list, &data, &DEVPKEY_Device_ClassGuid, &type, (PBYTE)guid, size, &size, 0);
wchar_t name[64];
StringFromGUID2(*guid, (LPOLESTR)name, ARRAYSIZE(name));
wprintf(L" class guid: %s\n", name);
free(guid);
}
}
SetupDiDestroyDeviceInfoList(list);
Это выведет что-то вроде этого:
name: ACPI Fan
class: System
class guid: {4D36E97D-E325-11CE-BFC1-08002BE10318}
name: ACPI Fan
class: System
class guid: {4D36E97D-E325-11CE-BFC1-08002BE10318}
name: ACPI Fan
class: System
class guid: {4D36E97D-E325-11CE-BFC1-08002BE10318}
name: ACPI Fan
class: System
class guid: {4D36E97D-E325-11CE-BFC1-08002BE10318}
name: ACPI Fan
class: System
class guid: {4D36E97D-E325-11CE-BFC1-08002BE10318}
name: Microsoft Hyper-V Virtual Machine Bus Provider
class: System
class guid: {4D36E97D-E325-11CE-BFC1-08002BE10318}
name: Plug and Play Software Device Enumerator
class: System
class guid: {4D36E97D-E325-11CE-BFC1-08002BE10318}
etc...