SetupDiDestroyDeviceInfoList(hDevInfo); std::wcout << L"Removed " << removed << L" non-present device(s).\n"; return 0;
if (!matches && g_verbose) DWORD hwIdSize = 0; SetupDiGetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_HARDWAREID, NULL, NULL, 0, &hwIdSize); if (hwIdSize > 0) std::vector<BYTE> buffer(hwIdSize); SetupDiGetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_HARDWAREID, NULL, buffer.data(), hwIdSize, &hwIdSize); WCHAR* hwid = (WCHAR*)buffer.data(); while (*hwid) if (id == hwid) matches = true; break; hwid += wcslen(hwid) + 1; DeviceCleanup.exe
while (SetupDiEnumDeviceInfo(hDevInfo, idx++, &devInfoData)) DEVINST devInst = devInfoData.DevInst; L"Removed " <