MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / EnumDevices

Method EnumDevices

WinSysCore/DeviceManager.cpp:28–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28std::vector<DeviceInfo> DeviceManager::EnumDevices() {
29 std::vector<DeviceInfo> devices;
30 SP_DEVINFO_DATA data = { sizeof(data) };
31 wchar_t name[512];
32
33 for (DWORD i = 0;; i++) {
34 if (!::SetupDiEnumDeviceInfo(_hInfoSet.get(), i, &data))
35 break;
36
37 DeviceInfo di;
38 di.Data = data;
39 if (::SetupDiGetDeviceRegistryProperty(_hInfoSet.get(), &data, SPDRP_FRIENDLYNAME, nullptr,
40 (BYTE*)name, sizeof(name), nullptr)) {
41 di.Description = name;
42 }
43 if (di.Description.empty()) {
44 if (::SetupDiGetDeviceRegistryProperty(_hInfoSet.get(), &data, SPDRP_DEVICEDESC, nullptr,
45 (BYTE*)name, sizeof(name), nullptr)) {
46 di.Description = name;
47 }
48 }
49 devices.push_back(std::move(di)); // �����ַ���
50 }
51 return devices;
52}
53
54std::wstring WinSys::DeviceManager::GetDeviceClassDescription(const GUID* guid, const wchar_t* computerName /* = nullptr */) {
55 wchar_t desc[256];

Callers 1

RefreshMethod · 0.80

Calls 2

emptyMethod · 0.80
push_backMethod · 0.80

Tested by

no test coverage detected