ReactOS  0.4.15-dev-1197-g8081ba9
hotplug.c File Reference
#include "hotplug.h"
#include <initguid.h>
#include <devguid.h>
#include <debug.h>
Include dependency graph for hotplug.c:

Go to the source code of this file.

Classes

struct  _HOTPLUG_DATA
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _HOTPLUG_DATA HOTPLUG_DATA
 
typedef struct _HOTPLUG_DATAPHOTPLUG_DATA
 

Functions

static DWORD GetHotPlugFlags (VOID)
 
static DWORD SetHotPlugFlags (_In_ DWORD dwFlags)
 
static HTREEITEM InsertDeviceTreeItem (_In_ HWND hwndDeviceTree, _In_ HTREEITEM hParent, _In_ DWORD DevInst, _In_ PHOTPLUG_DATA pHotplugData)
 
static VOID RecursiveInsertSubDevices (_In_ HWND hwndDeviceTree, _In_ HTREEITEM hParentItem, _In_ DWORD ParentDevInst, _In_ PHOTPLUG_DATA pHotplugData)
 
static VOID EnumHotpluggedDevices (HWND hwndDeviceTree, PHOTPLUG_DATA pHotplugData)
 
static VOID UpdateButtons (HWND hwndDlg)
 
static VOID ShowContextMenu (HWND hwndDlg, HWND hwndTreeView, PHOTPLUG_DATA pHotplugData)
 
INT_PTR CALLBACK SafeRemovalDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
LONG APIENTRY InitApplet (HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
 
LONG CALLBACK CPlApplet (HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
 
INT WINAPI DllMain (HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
 

Variables

HINSTANCE hApplet = 0
 
APPLET Applets [NUM_APPLETS]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file hotplug.c.

Typedef Documentation

◆ HOTPLUG_DATA

◆ PHOTPLUG_DATA

Function Documentation

◆ CPlApplet()

LONG CALLBACK CPlApplet ( HWND  hwndCPl,
UINT  uMsg,
LPARAM  lParam1,
LPARAM  lParam2 
)

Definition at line 497 of file hotplug.c.

502 {
503  UINT i = (UINT)lParam1;
504 
505  switch(uMsg)
506  {
507  case CPL_INIT:
508  return TRUE;
509 
510  case CPL_GETCOUNT:
511  return NUM_APPLETS;
512 
513  case CPL_INQUIRE:
514  {
515  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
516  CPlInfo->lData = 0;
517  CPlInfo->idIcon = Applets[i].idIcon;
518  CPlInfo->idName = Applets[i].idName;
519  CPlInfo->idInfo = Applets[i].idDescription;
520  }
521  break;
522 
523  case CPL_DBLCLK:
524  Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
525  break;
526 
527  case CPL_STARTWPARMSW:
528  return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
529  }
530  return FALSE;
531 }
Definition: cpl.h:24
#define TRUE
Definition: types.h:120
int idName
Definition: hotplug.h:36
int idIcon
Definition: hotplug.h:35
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:37
#define CPL_DBLCLK
Definition: cpl.h:16
APPLET Applets[NUM_APPLETS]
Definition: hotplug.c:30
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
APPLET_PROC AppletProc
Definition: hotplug.h:38
#define CPL_STARTWPARMSW
Definition: cpl.h:21
#define CPL_INIT
Definition: cpl.h:12
#define CPL_INQUIRE
Definition: cpl.h:14
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
unsigned int UINT
Definition: ndis.h:50
#define NUM_APPLETS
Definition: access.c:14
#define CPL_GETCOUNT
Definition: cpl.h:13

◆ DllMain()

INT WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  dwReason,
LPVOID  lpvReserved 
)

Definition at line 536 of file hotplug.c.

540 {
542 
543  switch (dwReason)
544  {
545  case DLL_PROCESS_ATTACH:
546  case DLL_THREAD_ATTACH:
547  hApplet = hinstDLL;
548  break;
549  }
550  return TRUE;
551 }
HINSTANCE hApplet
Definition: hotplug.c:27
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define DLL_THREAD_ATTACH
Definition: compat.h:132
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
static IN DWORD IN LPVOID lpvReserved
DWORD dwReason
Definition: misc.cpp:154

◆ EnumHotpluggedDevices()

static VOID EnumHotpluggedDevices ( HWND  hwndDeviceTree,
PHOTPLUG_DATA  pHotplugData 
)
static

Definition at line 229 of file hotplug.c.

232 {
233  SP_DEVINFO_DATA did = { 0 };
234  HDEVINFO hdev;
235  int idev;
236  DWORD dwCapabilities, dwSize;
237  ULONG ulStatus, ulProblem;
238  HTREEITEM hTreeItem;
239  CONFIGRET cr;
240 
241  DPRINT1("EnumHotpluggedDevices()\n");
242 
243  TreeView_DeleteAllItems(hwndDeviceTree);
244 
246  if (hdev == INVALID_HANDLE_VALUE)
247  return;
248 
249  did.cbSize = sizeof(did);
250 
251  /* Enumerate all the attached devices */
252  for (idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++)
253  {
254  ulStatus = 0;
255  ulProblem = 0;
256 
257  cr = CM_Get_DevNode_Status(&ulStatus,
258  &ulProblem,
259  did.DevInst,
260  0);
261  if (cr != CR_SUCCESS)
262  continue;
263 
264  dwCapabilities = 0,
265  dwSize = sizeof(dwCapabilities);
268  NULL,
269  &dwCapabilities,
270  &dwSize,
271  0);
272  if (cr != CR_SUCCESS)
273  continue;
274 
275  /* Add devices that require safe removal to the device tree */
276  if ( (dwCapabilities & CM_DEVCAP_REMOVABLE) &&
277  !(dwCapabilities & CM_DEVCAP_DOCKDEVICE) &&
278  !(dwCapabilities & CM_DEVCAP_SURPRISEREMOVALOK) &&
279  ((dwCapabilities & CM_DEVCAP_EJECTSUPPORTED) || (ulStatus & DN_DISABLEABLE)) &&
280  ulProblem == 0)
281  {
282  hTreeItem = InsertDeviceTreeItem(hwndDeviceTree,
283  TVI_ROOT,
284  did.DevInst,
285  pHotplugData);
286 
287  if ((hTreeItem != NULL) && (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS))
288  {
289  RecursiveInsertSubDevices(hwndDeviceTree,
290  hTreeItem,
291  did.DevInst,
292  pHotplugData);
293  }
294  }
295  }
296 
298 }
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1792
#define CM_Get_DevNode_Registry_Property
Definition: cfgmgr32.h:1733
#define CM_DEVCAP_REMOVABLE
Definition: cfgmgr32.h:737
#define CM_DEVCAP_EJECTSUPPORTED
Definition: cfgmgr32.h:736
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3413
DWORD dwFlags
Definition: hotplug.c:22
#define DN_DISABLEABLE
Definition: cfg.h:131
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define HOTPLUG_DISPLAY_DEVICE_COMPONENTS
Definition: hotplug.h:24
static VOID RecursiveInsertSubDevices(_In_ HWND hwndDeviceTree, _In_ HTREEITEM hParentItem, _In_ DWORD ParentDevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:172
static HTREEITEM InsertDeviceTreeItem(_In_ HWND hwndDeviceTree, _In_ HTREEITEM hParent, _In_ DWORD DevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:106
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TVI_ROOT
Definition: commctrl.h:3364
#define DIGCF_ALLCLASSES
Definition: setupapi.h:172
#define SetupDiGetClassDevs
Definition: setupapi.h:2588
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DPRINT1
Definition: precomp.h:8
CONFIGRET WINAPI CM_Get_DevNode_Status(_Out_ PULONG pulStatus, _Out_ PULONG pulProblemNumber, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:3565
unsigned int ULONG
Definition: retypes.h:1
#define CM_DEVCAP_SURPRISEREMOVALOK
Definition: cfgmgr32.h:742
#define CM_DEVCAP_DOCKDEVICE
Definition: cfgmgr32.h:738
_In_ HDEV hdev
Definition: winddi.h:3449
#define CM_DRP_CAPABILITIES
Definition: cfgmgr32.h:691
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define DIGCF_PRESENT
Definition: setupapi.h:171

Referenced by SafeRemovalDlgProc().

◆ GetHotPlugFlags()

static DWORD GetHotPlugFlags ( VOID  )
static

Definition at line 37 of file hotplug.c.

38 {
39  HKEY hKey = NULL;
40  DWORD dwFlags = 0;
41  DWORD dwSize, dwError;
42 
45  0,
46  KEY_READ,
47  &hKey);
48  if (dwError != ERROR_SUCCESS)
49  goto done;
50 
51  dwSize = sizeof(dwFlags);
52  dwError = RegQueryValueExW(hKey,
53  L"HotPlugFlags",
54  NULL,
55  NULL,
56  (LPBYTE)&dwFlags,
57  &dwSize);
58  if (dwError != ERROR_SUCCESS)
59  dwFlags = 0;
60 
61 done:
62  if (hKey != NULL)
63  RegCloseKey(hKey);
64 
65  return dwFlags;
66 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define REGSTR_PATH_SYSTRAY
Definition: regstr.h:531
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by SafeRemovalDlgProc().

◆ InitApplet()

LONG APIENTRY InitApplet ( HWND  hwnd,
UINT  uMsg,
LPARAM  wParam,
LPARAM  lParam 
)

Definition at line 477 of file hotplug.c.

482 {
483  DPRINT("InitApplet()\n");
484 
487  hwnd,
489 
490  // TODO
491  return TRUE;
492 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
HINSTANCE hApplet
Definition: hotplug.c:27
#define TRUE
Definition: types.h:120
#define DialogBox
Definition: winuser.h:5736
void DPRINT(...)
Definition: polytest.cpp:61
#define IDD_SAFE_REMOVE_HARDWARE_DIALOG
Definition: resource.h:9
INT_PTR CALLBACK SafeRemovalDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hotplug.c:347

◆ InsertDeviceTreeItem()

static HTREEITEM InsertDeviceTreeItem ( _In_ HWND  hwndDeviceTree,
_In_ HTREEITEM  hParent,
_In_ DWORD  DevInst,
_In_ PHOTPLUG_DATA  pHotplugData 
)
static

Definition at line 106 of file hotplug.c.

111 {
112  WCHAR szDisplayName[40];
113  WCHAR szGuidString[MAX_GUID_STRING_LEN];
114  TVINSERTSTRUCTW tvItem;
115  GUID ClassGuid;
116  INT nClassImage;
117  DWORD dwSize;
118  CONFIGRET cr;
119 
120  /* Get the device description */
121  dwSize = sizeof(szDisplayName);
124  NULL,
125  szDisplayName,
126  &dwSize,
127  0);
128  if (cr != CR_SUCCESS)
129  wcscpy(szDisplayName, L"Unknown Device");
130 
131  /* Get the class GUID */
132  dwSize = sizeof(szGuidString);
135  NULL,
136  szGuidString,
137  &dwSize,
138  0);
139  if (cr == CR_SUCCESS)
140  {
141  pSetupGuidFromString(szGuidString, &ClassGuid);
142  }
143  else
144  {
145  memcpy(&ClassGuid, &GUID_DEVCLASS_UNKNOWN, sizeof(GUID));
146  }
147 
148  /* Get the image for the class this device is in */
149  SetupDiGetClassImageIndex(&pHotplugData->ImageListData,
150  &ClassGuid,
151  &nClassImage);
152 
153  /* Add it to the device tree */
154  ZeroMemory(&tvItem, sizeof(tvItem));
155  tvItem.hParent = hParent;
156  tvItem.hInsertAfter = TVI_LAST;
157 
158  tvItem.item.mask = TVIF_STATE | TVIF_TEXT /*| TVIF_PARAM*/ | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
159  tvItem.item.state = TVIS_EXPANDED;
160  tvItem.item.stateMask = TVIS_EXPANDED;
161  tvItem.item.pszText = szDisplayName;
162  tvItem.item.iImage = nClassImage;
163  tvItem.item.iSelectedImage = nClassImage;
164  tvItem.item.lParam = (LPARAM)NULL;
165 
166  return TreeView_InsertItem(hwndDeviceTree, &tvItem);
167 }
#define CM_Get_DevNode_Registry_Property
Definition: cfgmgr32.h:1733
HTREEITEM hParent
Definition: commctrl.h:3389
#define ZeroMemory
Definition: winbase.h:1648
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3267
int32_t INT
Definition: typedefs.h:58
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3408
HTREEITEM hInsertAfter
Definition: commctrl.h:3390
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
LONG_PTR LPARAM
Definition: windef.h:208
#define TVI_LAST
Definition: commctrl.h:3366
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI SetupDiGetClassImageIndex(IN PSP_CLASSIMAGELIST_DATA ClassImageListData, IN CONST GUID *ClassGuid, OUT PINT ImageIndex)
Definition: devclass.c:396
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define CM_DRP_DEVICEDESC
Definition: cfgmgr32.h:676
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define TVIS_EXPANDED
Definition: commctrl.h:3280
#define TVIF_TEXT
Definition: commctrl.h:3262
#define TVIF_IMAGE
Definition: commctrl.h:3263
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define TVIF_STATE
Definition: commctrl.h:3265
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
DWORD WINAPI pSetupGuidFromString(PCWSTR pString, LPGUID lpGUID)
Definition: misc.c:1751

Referenced by EnumHotpluggedDevices(), and RecursiveInsertSubDevices().

◆ RecursiveInsertSubDevices()

static VOID RecursiveInsertSubDevices ( _In_ HWND  hwndDeviceTree,
_In_ HTREEITEM  hParentItem,
_In_ DWORD  ParentDevInst,
_In_ PHOTPLUG_DATA  pHotplugData 
)
static

Definition at line 172 of file hotplug.c.

177 {
178  HTREEITEM hTreeItem;
179  DEVINST ChildDevInst;
180  CONFIGRET cr;
181 
182  DPRINT("RecursiveInsertSubDevices()\n");
183 
184  cr = CM_Get_Child(&ChildDevInst, ParentDevInst, 0);
185  if (cr != CR_SUCCESS)
186  {
187  DPRINT("No child! %lu\n", cr);
188  return;
189  }
190 
191  hTreeItem = InsertDeviceTreeItem(hwndDeviceTree,
192  hParentItem,
193  ChildDevInst,
194  pHotplugData);
195  if (hTreeItem != NULL)
196  {
197  RecursiveInsertSubDevices(hwndDeviceTree,
198  hTreeItem,
199  ChildDevInst,
200  pHotplugData);
201  }
202 
203  for (;;)
204  {
205  cr = CM_Get_Sibling(&ChildDevInst, ChildDevInst, 0);
206  if (cr != CR_SUCCESS)
207  {
208  DPRINT("No sibling! %lu\n", cr);
209  return;
210  }
211 
212  hTreeItem = InsertDeviceTreeItem(hwndDeviceTree,
213  hParentItem,
214  ChildDevInst,
215  pHotplugData);
216  if (hTreeItem != NULL)
217  {
218  RecursiveInsertSubDevices(hwndDeviceTree,
219  hTreeItem,
220  ChildDevInst,
221  pHotplugData);
222  }
223  }
224 }
CONFIGRET WINAPI CM_Get_Sibling(_Out_ PDEVINST pdnDevInst, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:5522
static VOID RecursiveInsertSubDevices(_In_ HWND hwndDeviceTree, _In_ HTREEITEM hParentItem, _In_ DWORD ParentDevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:172
static HTREEITEM InsertDeviceTreeItem(_In_ HWND hwndDeviceTree, _In_ HTREEITEM hParent, _In_ DWORD DevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:106
CONFIGRET WINAPI CM_Get_Child(_Out_ PDEVINST pdnDevInst, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:2522
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
DWORD DEVINST
Definition: cfgmgr32.h:76
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74

Referenced by EnumHotpluggedDevices().

◆ SafeRemovalDlgProc()

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

Definition at line 347 of file hotplug.c.

352 {
353  PHOTPLUG_DATA pHotplugData;
354 
355  pHotplugData = (PHOTPLUG_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
356 
357  switch (uMsg)
358  {
359  case WM_INITDIALOG:
360  pHotplugData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HOTPLUG_DATA));
361  if (pHotplugData != NULL)
362  {
363  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pHotplugData);
364 
365  pHotplugData->ImageListData.cbSize = sizeof(pHotplugData->ImageListData);
366  SetupDiGetClassImageList(&pHotplugData->ImageListData);
367 
369 
370  pHotplugData->dwFlags = GetHotPlugFlags();
371 
372  if (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS)
374 
376  pHotplugData->ImageListData.ImageList,
377  TVSIL_NORMAL);
378 
380  pHotplugData);
381  UpdateButtons(hwndDlg);
382  }
383  return TRUE;
384 
385  case WM_COMMAND:
386  switch (LOWORD(wParam))
387  {
388  case IDCLOSE:
389  KillTimer(hwndDlg, 1);
390  EndDialog(hwndDlg, TRUE);
391  break;
392 
394  if (HIWORD(wParam) == BN_CLICKED)
395  {
396  if (pHotplugData != NULL)
397  {
400  else
401  pHotplugData->dwFlags &= ~HOTPLUG_DISPLAY_DEVICE_COMPONENTS;
402 
403  SetHotPlugFlags(pHotplugData->dwFlags);
404 
406  pHotplugData);
407  }
408  }
409  break;
410  }
411  break;
412 
413  case WM_DEVICECHANGE:
414  switch (wParam)
415  {
417  SetTimer(hwndDlg, 1, 500, NULL);
418  break;
419  }
420  break;
421 
422  case WM_TIMER:
423  if (wParam == 1)
424  {
425  KillTimer(hwndDlg, 1);
426 
427  if (pHotplugData != NULL)
428  {
430  pHotplugData);
431  UpdateButtons(hwndDlg);
432  }
433  }
434  break;
435 
436  case WM_NOTIFY:
437  if (((LPNMHDR)lParam)->idFrom == IDC_SAFE_REMOVE_DEVICE_TREE)
438  {
439  if (((LPNMHDR)lParam)->code == NM_RCLICK)
440  {
441  if (pHotplugData != NULL)
442  {
443  ShowContextMenu(hwndDlg,
444  ((LPNMHDR)lParam)->hwndFrom,
445  pHotplugData);
446  return TRUE;
447  }
448  }
449  }
450  break;
451 
452  case WM_CLOSE:
453  KillTimer(hwndDlg, 1);
454  EndDialog(hwndDlg, TRUE);
455  break;
456 
457  case WM_DESTROY:
458  if (pHotplugData != NULL)
459  {
460  if (pHotplugData->hPopupMenu != NULL)
461  DestroyMenu(pHotplugData->hPopupMenu);
462 
464 
465  HeapFree(GetProcessHeap(), 0, pHotplugData);
467  }
468  break;
469  }
470 
471  return FALSE;
472 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DBT_DEVNODES_CHANGED
Definition: dbt.h:28
HINSTANCE hApplet
Definition: hotplug.c:27
#define TRUE
Definition: types.h:120
static DWORD SetHotPlugFlags(_In_ DWORD dwFlags)
Definition: hotplug.c:71
DWORD dwFlags
Definition: hotplug.c:22
#define HOTPLUG_DISPLAY_DEVICE_COMPONENTS
Definition: hotplug.h:24
BOOL WINAPI SetupDiGetClassImageList(OUT PSP_CLASSIMAGELIST_DATA ClassImageListData)
Definition: devclass.c:441
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
static VOID UpdateButtons(HWND hwndDlg)
Definition: hotplug.c:303
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetupDiDestroyClassImageList(IN PSP_CLASSIMAGELIST_DATA ClassImageListData)
Definition: devclass.c:85
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3443
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1591
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static VOID EnumHotpluggedDevices(HWND hwndDeviceTree, PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:229
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDM_POPUP_DEVICE_TREE
Definition: resource.h:20
#define WM_TIMER
Definition: winuser.h:1724
#define WM_CLOSE
Definition: winuser.h:1603
#define Button_GetCheck(hwndCtl)
Definition: windowsx.h:6
#define BN_CLICKED
Definition: winuser.h:1907
SP_CLASSIMAGELIST_DATA ImageListData
Definition: hotplug.c:20
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
struct _HOTPLUG_DATA * PHOTPLUG_DATA
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
Definition: inflate.c:139
BOOL WINAPI DestroyMenu(_In_ HMENU)
static DWORD GetHotPlugFlags(VOID)
Definition: hotplug.c:37
#define LoadMenu
Definition: winuser.h:5792
#define NM_RCLICK
Definition: commctrl.h:133
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDC_SAFE_REMOVE_DEVICE_TREE
Definition: resource.h:11
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define BST_CHECKED
Definition: winuser.h:197
#define WM_DEVICECHANGE
Definition: winuser.h:1793
#define Button_SetCheck(hwndCtl, check)
Definition: windowsx.h:10
#define TVSIL_NORMAL
Definition: commctrl.h:3439
#define HIWORD(l)
Definition: typedefs.h:247
#define GetWindowLongPtr
Definition: treelist.c:73
static VOID ShowContextMenu(HWND hwndDlg, HWND hwndTreeView, PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:317
HMENU hPopupMenu
Definition: hotplug.c:21
#define IDC_SAFE_REMOVE_DISPLAY_COMPONENTS
Definition: resource.h:15
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:483
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by InitApplet().

◆ SetHotPlugFlags()

static DWORD SetHotPlugFlags ( _In_ DWORD  dwFlags)
static

Definition at line 71 of file hotplug.c.

73 {
74  HKEY hKey = NULL;
75  DWORD dwError;
76 
79  0,
80  NULL,
82  KEY_WRITE,
83  NULL,
84  &hKey,
85  NULL);
86  if (dwError != ERROR_SUCCESS)
87  goto done;
88 
89  dwError = RegSetValueExW(hKey,
90  L"HotPlugFlags",
91  0,
92  REG_DWORD,
93  (LPBYTE)&dwFlags,
94  sizeof(dwFlags));
95 
96 done:
97  if (hKey != NULL)
98  RegCloseKey(hKey);
99 
100  return dwError;
101 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define REGSTR_PATH_SYSTRAY
Definition: regstr.h:531
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by SafeRemovalDlgProc().

◆ ShowContextMenu()

static VOID ShowContextMenu ( HWND  hwndDlg,
HWND  hwndTreeView,
PHOTPLUG_DATA  pHotplugData 
)
static

Definition at line 317 of file hotplug.c.

321 {
322  HTREEITEM hTreeItem;
323  RECT rc;
324  POINT pt;
325 
326  hTreeItem = TreeView_GetSelection(hwndTreeView);
327  if (hTreeItem == NULL)
328  return;
329 
330  TreeView_GetItemRect(hwndTreeView, hTreeItem, &rc, TRUE);
331 
332  pt.x = (rc.left + rc.right) / 2;
333  pt.y = (rc.top + rc.bottom) / 2;
335  TrackPopupMenu(GetSubMenu(pHotplugData->hPopupMenu, 0),
337  pt.x,
338  pt.y,
339  0,
340  hwndDlg,
341  NULL);
342 }
#define TreeView_GetItemRect(hwnd, hitem, prc, code)
Definition: commctrl.h:3425
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
#define TPM_LEFTALIGN
Definition: winuser.h:2352
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define TPM_TOPALIGN
Definition: winuser.h:2358
smooth NULL
Definition: ftsmooth.c:416
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3469
HWND hwndTreeView
Definition: eventvwr.c:82
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
LONG bottom
Definition: windef.h:309
HMENU hPopupMenu
Definition: hotplug.c:21
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)

Referenced by OpenDialogProc(), SafeRemovalDlgProc(), SaveDialogProc(), and VfdPageDlgProc().

◆ UpdateButtons()

static VOID UpdateButtons ( HWND  hwndDlg)
static

Definition at line 303 of file hotplug.c.

305 {
306  BOOL bEnabled;
307 
308  bEnabled = (TreeView_GetCount(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE)) != 0);
309 
311  EnableWindow(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_STOP), bEnabled);
312 }
#define IDC_SAFE_REMOVE_STOP
Definition: resource.h:14
#define TreeView_GetCount(hwnd)
Definition: commctrl.h:3428
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define IDC_SAFE_REMOVE_DEVICE_TREE
Definition: resource.h:11
#define IDC_SAFE_REMOVE_PROPERTIES
Definition: resource.h:13

Referenced by SafeRemovalDlgProc().

Variable Documentation

◆ Applets

APPLET Applets[NUM_APPLETS]
Initial value:
=
{
}
#define IDI_HOTPLUG
Definition: resource.h:4
#define IDS_CPLNAME
Definition: resource.h:8
#define IDS_CPLDESCRIPTION
Definition: resource.h:9
LONG APIENTRY InitApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: hotplug.c:477

Definition at line 30 of file hotplug.c.

Referenced by CPlApplet().

◆ hApplet

HINSTANCE hApplet = 0

Definition at line 27 of file hotplug.c.

Referenced by DllMain(), InitApplet(), and SafeRemovalDlgProc().