ReactOS 0.4.15-dev-7961-gdcf9eb0
eject.c File Reference
#include "hotplug.h"
#include <strsafe.h>
Include dependency graph for eject.c:

Go to the source code of this file.

Functions

DEVINST GetDeviceInstForRemoval (_In_ PHOTPLUG_DATA pHotplugData)
 
static VOID FillConfirmDeviceList (_In_ HWND hwndCfmDeviceList, _In_ PHOTPLUG_DATA pHotplugData)
 
static VOID SafeRemoveDevice (_In_ DEVINST DevInst, _In_opt_ HWND hwndDlg)
 
INT_PTR CALLBACK ConfirmRemovalDlgProc (_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 

Function Documentation

◆ ConfirmRemovalDlgProc()

INT_PTR CALLBACK ConfirmRemovalDlgProc ( _In_ HWND  hwndDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)

Definition at line 84 of file eject.c.

89{
90 PHOTPLUG_DATA pHotplugData;
91
92 pHotplugData = (PHOTPLUG_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
93
94 switch (uMsg)
95 {
96 case WM_INITDIALOG:
97 {
98 HWND hwndDevList;
99
100 pHotplugData = (PHOTPLUG_DATA)lParam;
101 SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pHotplugData);
102
103 hwndDevList = GetDlgItem(hwndDlg, IDC_CONFIRM_STOP_DEVICE_LIST);
104
105 ListView_SetImageList(hwndDevList,
106 pHotplugData->ImageListData.ImageList,
108
109 FillConfirmDeviceList(hwndDevList, pHotplugData);
110
111 return TRUE;
112 }
113
114 case WM_COMMAND:
115 {
116 switch (LOWORD(wParam))
117 {
118 case IDOK:
119 SafeRemoveDevice(GetDeviceInstForRemoval(pHotplugData), hwndDlg);
120 EndDialog(hwndDlg, LOWORD(wParam));
121 break;
122
123 case IDCANCEL:
124 EndDialog(hwndDlg, LOWORD(wParam));
125 break;
126 }
127
128 break;
129 }
130
131 case WM_DESTROY:
133 break;
134 }
135
136 return FALSE;
137}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_CONFIRM_STOP_DEVICE_LIST
Definition: resource.h:18
DEVINST GetDeviceInstForRemoval(_In_ PHOTPLUG_DATA pHotplugData)
Definition: eject.c:13
static VOID FillConfirmDeviceList(_In_ HWND hwndCfmDeviceList, _In_ PHOTPLUG_DATA pHotplugData)
Definition: eject.c:42
static VOID SafeRemoveDevice(_In_ DEVINST DevInst, _In_opt_ HWND hwndDlg)
Definition: eject.c:60
struct _HOTPLUG_DATA * PHOTPLUG_DATA
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define LVSIL_SMALL
Definition: commctrl.h:2299
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
SP_CLASSIMAGELIST_DATA ImageListData
Definition: hotplug.h:45
#define DWLP_USER
Definition: winuser.h:872
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define WM_DESTROY
Definition: winuser.h:1609
#define SetWindowLongPtrW
Definition: winuser.h:5346
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by SafeRemovalDlgProc().

◆ FillConfirmDeviceList()

static VOID FillConfirmDeviceList ( _In_ HWND  hwndCfmDeviceList,
_In_ PHOTPLUG_DATA  pHotplugData 
)
static

Definition at line 42 of file eject.c.

45{
46 LVCOLUMNW lvColumn;
47
48 ZeroMemory(&lvColumn, sizeof(lvColumn));
49 lvColumn.mask = LVCF_FMT;
50 lvColumn.fmt = LVCFMT_LEFT | LVCFMT_IMAGE;
51 ListView_InsertColumn(hwndCfmDeviceList, 0, &lvColumn);
52
53 CfmListEnumDevices(hwndCfmDeviceList, pHotplugData);
54
56}
VOID CfmListEnumDevices(_In_ HWND hwndCfmDeviceList, _In_ PHOTPLUG_DATA pHotplugData)
Definition: enum.c:272
#define LVCFMT_IMAGE
Definition: commctrl.h:2602
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2636
#define ListView_SetColumnWidth(hwnd, iCol, cx)
Definition: commctrl.h:2648
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define LVSCW_AUTOSIZE_USEHEADER
Definition: commctrl.h:2645
#define ZeroMemory
Definition: winbase.h:1712

Referenced by ConfirmRemovalDlgProc().

◆ GetDeviceInstForRemoval()

DEVINST GetDeviceInstForRemoval ( _In_ PHOTPLUG_DATA  pHotplugData)

Definition at line 13 of file eject.c.

15{
16 HTREEITEM hItem, hParentItem;
17 TVITEMW tvItem;
18
19 hItem = TreeView_GetSelection(pHotplugData->hwndDeviceTree);
20 if (!hItem)
21 return 0;
22
23 /* Find root item */
24 hParentItem = TreeView_GetParent(pHotplugData->hwndDeviceTree, hItem);
25 while (hParentItem)
26 {
27 hItem = hParentItem;
28 hParentItem = TreeView_GetParent(pHotplugData->hwndDeviceTree, hItem);
29 }
30
31 ZeroMemory(&tvItem, sizeof(tvItem));
32 tvItem.mask = TVIF_PARAM;
33 tvItem.hItem = hItem;
34
35 TreeView_GetItem(pHotplugData->hwndDeviceTree, &tvItem);
36
37 return tvItem.lParam;
38}
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TVIF_PARAM
Definition: commctrl.h:3268
HTREEITEM hItem
Definition: commctrl.h:3317
LPARAM lParam
Definition: commctrl.h:3325
UINT mask
Definition: commctrl.h:3316
HTREEITEM hItem
Definition: treelist.h:37

Referenced by CfmListEnumDevices(), and ConfirmRemovalDlgProc().

◆ SafeRemoveDevice()

static VOID SafeRemoveDevice ( _In_ DEVINST  DevInst,
_In_opt_ HWND  hwndDlg 
)
static

Definition at line 60 of file eject.c.

63{
65 CONFIGRET cr;
66
67 cr = CM_Request_Device_EjectW(DevInst, &VetoType, NULL, 0, 0);
68 if (cr != CR_SUCCESS && VetoType == PNP_VetoTypeUnknown)
69 {
70 LPCWSTR pszFormat = L"";
71 WCHAR szError[64];
72
73 /* NOTES: IDS_EJECT_ERROR_FORMAT resource has to be explicitly NULL-terminated
74 * so we can use the string directly without having to make a copy of it. */
76 StringCbPrintfW(szError, sizeof(szError), pszFormat, cr);
77
78 MessageBoxW(hwndDlg, szError, NULL, MB_ICONEXCLAMATION | MB_OK);
79 }
80}
@ PNP_VetoTypeUnknown
Definition: cfg.h:180
enum _PNP_VETO_TYPE PNP_VETO_TYPE
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_SUCCESS
Definition: cfgmgr32.h:842
CONFIGRET WINAPI CM_Request_Device_EjectW(_In_ DEVINST dnDevInst, _Out_opt_ PPNP_VETO_TYPE pVetoType, _Out_writes_opt_(ulNameLength) LPWSTR pszVetoName, _In_ ULONG ulNameLength, _In_ ULONG ulFlags)
Definition: cfgmgr.c:7457
HINSTANCE hApplet
Definition: access.c:17
#define IDS_EJECT_ERROR_FORMAT
Definition: resource.h:29
#define L(x)
Definition: ntvdm.h:50
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define MB_OK
Definition: winuser.h:790
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ConfirmRemovalDlgProc().