Skip to content

Commit

Permalink
[HOTPLUG] **WIP** Add device removal support
Browse files Browse the repository at this point in the history
  • Loading branch information
TAN-Gaming committed Oct 26, 2023
1 parent 7f5c59a commit e0b74f3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dll/cpl/hotplug/hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,23 @@ ShowDeviceProperties(
HeapFree(GetProcessHeap(), 0, pszDevId);
}

static
VOID
SafeRemoveDevice(
_In_ DEVINST DevInst,
_In_opt_ HWND hwndDlg)
{
CONFIGRET cr;

cr = CM_Request_Device_EjectW(DevInst, NULL, NULL, MAX_PATH, 0);
if (cr != CR_SUCCESS)
{
WCHAR szError[40];
swprintf(szError, L"Failed to remove device (0x%x)", cr);
MessageBoxW(hwndDlg, szError, NULL, MB_ICONEXCLAMATION | MB_OK);
}
}

INT_PTR
CALLBACK
SafeRemovalDlgProc(
Expand Down Expand Up @@ -505,6 +522,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;

Expand Down

0 comments on commit e0b74f3

Please sign in to comment.