diff --git a/dll/cpl/hotplug/hotplug.c b/dll/cpl/hotplug/hotplug.c index 15dea9c7583b8..4e43894c924e6 100644 --- a/dll/cpl/hotplug/hotplug.c +++ b/dll/cpl/hotplug/hotplug.c @@ -407,6 +407,25 @@ ShowDeviceProperties( HeapFree(GetProcessHeap(), 0, pszDevId); } +static +VOID +SafeRemoveDevice( + _In_ DEVINST DevInst, + _In_opt_ HWND hwndDlg) +{ + WCHAR szError[MAX_PATH] = L""; + CONFIGRET cr; + + cr = CM_Request_Device_EjectW(DevInst, NULL, szError, ARRAYSIZE(szError), 0); + if (cr != CR_SUCCESS) + { + if (!*szError) + swprintf(szError, ARRAYSIZE(szError), L"Failed to remove device (0x%x)", cr); + + MessageBoxW(hwndDlg, szError, L"Error", MB_ICONEXCLAMATION | MB_OK); + } +} + INT_PTR CALLBACK SafeRemovalDlgProc( @@ -505,6 +524,14 @@ SafeRemovalDlgProc( ShowDeviceProperties(hwndDlg, GetSelectedDeviceInst(hwndDevTree)); break; } + + case IDC_SAFE_REMOVE_STOP: + case IDM_STOP: + { + HWND hwndDevTree = GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE); + SafeRemoveDevice(GetSelectedDeviceInst(hwndDevTree), hwndDlg); + break; + } } break;