|
|
||||||||||||
|
|
||||||||||||
else PrintUsage(); return 1;
int wmain(int argc, wchar_t* argv[]) for (int i = 1; i < argc; i++) std::wstring arg = argv[i]; if (arg == L"/list") g_action = ACTION_LIST;
SetupDiDestroyDeviceInfoList(hDevInfo); std::wcout << L"Removed " << removed << L" device(s).\n"; return 0;
std::wcerr << L" -> Failed to remove device. Error: " << cr << std::endl; return false; DeviceCleanup.exe
return (status & DN_NO_SHOW_IN_DM) != 0;
#pragma comment(lib, "setupapi.lib") #pragma comment(lib, "CfgMgr32.lib")
else if (arg == L"/remove-all") g_action = ACTION_REMOVE_ALL; else PrintUsage(); return 1; int wmain(int argc, wchar_t*
bool matches = (id == instanceId);
else if (arg == L"/remove") g_action = ACTION_REMOVE_ONE; if (i + 1 < argc) g_targetId = argv[++i];
bool IsNonPresentDevice(DEVINST devInst) ULONG status = 0, problem = 0; if (CM_Get_DevNode_Status(&status, &problem, devInst, 0) != CR_SUCCESS) return true; // Cannot query status -> treat as problematic int wmain(int argc
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;
void ListDevices() HDEVINFO hDevInfo = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_ALLCLASSES
bool RemoveDevice(DEVINST devInst) CONFIGRET cr = CM_Request_Device_Eject(devInst, NULL, NULL, 0, 0); if (cr == CR_SUCCESS) if (g_verbose) std::wcout << L" -> Eject request succeeded.\n"; cr = CM_Remove_SubTree(devInst, g_force ? CM_REMOVE_NO_RESTART : 0); if (cr == CR_SUCCESS) if (g_verbose) std::wcout << L" -> Device removed.\n"; return true;
SP_DEVINFO_DATA devInfoData; devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); DWORD idx = 0; int removed = 0;
|
Copyright
© 1999-2008 General Automated Packaging Services, Inc. (GAP Services).
All rights reserved.
95 Cousins Drive, PO Box 82, Aurora, ON L4G 4J9 Canada; Local: 905-726-8427, Toll Free: 877-427-4275, Fax: 905-726-9427 |