Skip to content

Commit

Permalink
[HOTPLUG] Add device removal function
Browse files Browse the repository at this point in the history
  • Loading branch information
TAN-Gaming committed Oct 27, 2023
1 parent 7f5c59a commit ea4424c
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)
{
PNP_VETO_TYPE VetoType = PNP_VetoTypeUnknown;
CONFIGRET cr;

cr = CM_Request_Device_EjectW(DevInst, &VetoType, NULL, 0, 0);
if (cr != CR_SUCCESS && VetoType == PNP_VetoTypeUnknown)
{
WCHAR szError[64];
swprintf(szError, L"Failed to remove device (0x%x)", cr);
MessageBoxW(NULL, 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));
break;
}
}
break;

Expand Down

0 comments on commit ea4424c

Please sign in to comment.