forked from reactos/reactos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HOTPLUG] **WIP** Implement "Stop a Hardware Device" dialog
- Loading branch information
1 parent
ea4424c
commit b6ab881
Showing
6 changed files
with
90 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* PROJECT: ReactOS Safely Remove Hardware Applet | ||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) | ||
* PURPOSE: Hardware safe removal support | ||
* COPYRIGHT: Copyright 2023 Thamatip Chitpong <[email protected]> | ||
*/ | ||
|
||
#include "hotplug.h" | ||
|
||
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 | ||
ConfirmRemovalDlgProc( | ||
HWND hwndDlg, | ||
UINT uMsg, | ||
WPARAM wParam, | ||
LPARAM lParam) | ||
{ | ||
static DEVINST selectedDev; | ||
|
||
switch (uMsg) | ||
{ | ||
case WM_INITDIALOG: | ||
selectedDev = lParam; | ||
return TRUE; | ||
|
||
case WM_COMMAND: | ||
{ | ||
switch (LOWORD(wParam)) | ||
{ | ||
case IDCANCEL: | ||
case IDCLOSE: | ||
EndDialog(hwndDlg, TRUE); | ||
break; | ||
|
||
case IDOK: | ||
SafeRemoveDevice(selectedDev); | ||
EndDialog(hwndDlg, TRUE); | ||
break; | ||
} | ||
|
||
break; | ||
} | ||
} | ||
|
||
return FALSE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters