Devicecleanup.exe -

if (matches && IsNonPresentDevice(devInst)) std::wcout << L"Removing: " << instanceId << std::endl; if (RemoveDevice(devInst)) removed++;

#pragma comment(lib, "setupapi.lib") #pragma comment(lib, "CfgMgr32.lib")

void ListDevices() DIGCF_PRESENT); if (hDevInfo == INVALID_HANDLE_VALUE) std::wcerr << L"Failed to get device list. Error: " << GetLastError() << std::endl; return; DeviceCleanup.exe

SP_DEVINFO_DATA devInfoData; devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); DWORD idx = 0; int count = 0;

if (g_verbose) // Get hardware IDs 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(); std::wcout << L" Hardware IDs: "; while (*hwid) std::wcout << hwid << L" "; hwid += wcslen(hwid) + 1; std::wcout << std::endl; std::wcout << std::endl; if (matches && IsNonPresentDevice(devInst)) std::wcout &lt

std::wcerr << L" -> Failed to remove device. Error: " << cr << std::endl; return false;

enum Action ACTION_LIST, ACTION_REMOVE_ONE, ACTION_REMOVE_ALL ; Action g_action = ACTION_LIST; std::wstring g_targetId; bool g_force = false; bool g_verbose = false; L"Removing: " &lt

SP_DEVINFO_DATA devInfoData; devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); DWORD idx = 0; int removed = 0;