2017-08-18 14:49:11 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: dll/shellext/stobject/hotplug.cpp
|
2017-10-16 14:11:10 +00:00
|
|
|
* PURPOSE: Removable devices notification icon handler
|
2021-09-13 01:33:14 +00:00
|
|
|
* PROGRAMMERS: Shriraj Sawant a.k.a SR13 <sr.official@hotmail.com>
|
2017-08-18 14:49:11 +00:00
|
|
|
*/
|
2017-12-08 22:15:31 +00:00
|
|
|
|
2017-08-18 14:49:11 +00:00
|
|
|
#include "precomp.h"
|
2017-12-08 22:15:31 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
#include <atlsimpcoll.h>
|
|
|
|
#include <dbt.h>
|
|
|
|
#include <cfgmgr32.h>
|
2017-12-08 22:15:31 +00:00
|
|
|
#include <shlwapi.h>
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
#define DISPLAY_NAME_LEN 40
|
|
|
|
|
|
|
|
CSimpleArray<DEVINST> g_devList;
|
2020-03-22 10:31:56 +00:00
|
|
|
CString g_strHotplugTooltip;
|
2017-08-18 14:49:11 +00:00
|
|
|
static HICON g_hIconHotplug = NULL;
|
2017-10-16 14:11:10 +00:00
|
|
|
static WCHAR g_strMenuSel[DISPLAY_NAME_LEN];
|
|
|
|
static BOOL g_IsRemoving = FALSE;
|
|
|
|
|
|
|
|
/*++
|
|
|
|
* @name EnumHotpluggedDevices
|
|
|
|
*
|
|
|
|
* Enumerates the connected safely removable devices.
|
|
|
|
*
|
|
|
|
* @param devList
|
|
|
|
* List of device instances, representing the currently attached devices.
|
|
|
|
*
|
|
|
|
* @return The error code.
|
|
|
|
*
|
|
|
|
*--*/
|
|
|
|
HRESULT EnumHotpluggedDevices(CSimpleArray<DEVINST> &devList)
|
2017-08-18 14:49:11 +00:00
|
|
|
{
|
2017-10-16 14:11:10 +00:00
|
|
|
devList.RemoveAll(); // Clear current devList
|
|
|
|
HDEVINFO hdev = SetupDiGetClassDevs(NULL, NULL, 0, DIGCF_ALLCLASSES | DIGCF_PRESENT);
|
|
|
|
if (INVALID_HANDLE_VALUE == hdev)
|
|
|
|
return E_HANDLE;
|
|
|
|
SP_DEVINFO_DATA did = { 0 };
|
|
|
|
did.cbSize = sizeof(did);
|
|
|
|
|
|
|
|
// Enumerate all the attached devices.
|
|
|
|
for (int idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++)
|
|
|
|
{
|
|
|
|
DWORD dwCapabilities = 0, dwSize = sizeof(dwCapabilities);
|
2020-03-22 10:31:56 +00:00
|
|
|
ULONG ulStatus = 0, ulProblem = 0;
|
|
|
|
CONFIGRET cr = CM_Get_DevNode_Status(&ulStatus, &ulProblem, did.DevInst, 0);
|
2017-10-16 14:11:10 +00:00
|
|
|
if (cr != CR_SUCCESS)
|
|
|
|
continue;
|
2020-03-22 10:31:56 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
cr = CM_Get_DevNode_Registry_Property(did.DevInst, CM_DRP_CAPABILITIES, NULL, &dwCapabilities, &dwSize, 0);
|
|
|
|
if (cr != CR_SUCCESS)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Filter and make list of only the appropriate safely removable devices.
|
|
|
|
if ( (dwCapabilities & CM_DEVCAP_REMOVABLE) &&
|
|
|
|
!(dwCapabilities & CM_DEVCAP_DOCKDEVICE) &&
|
|
|
|
!(dwCapabilities & CM_DEVCAP_SURPRISEREMOVALOK) &&
|
|
|
|
((dwCapabilities & CM_DEVCAP_EJECTSUPPORTED) || (ulStatus & DN_DISABLEABLE)) &&
|
2020-03-22 10:31:56 +00:00
|
|
|
!ulProblem)
|
2017-10-16 14:11:10 +00:00
|
|
|
{
|
|
|
|
devList.Add(did.DevInst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetupDiDestroyDeviceInfoList(hdev);
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
if (NO_ERROR != GetLastError() && ERROR_NO_MORE_ITEMS != GetLastError())
|
|
|
|
{
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
/*++
|
|
|
|
* @name NotifyBalloon
|
|
|
|
*
|
|
|
|
* Pops the balloon notification of the given notification icon.
|
|
|
|
*
|
|
|
|
* @param pSysTray
|
|
|
|
* Provides interface for acquiring CSysTray information as required.
|
|
|
|
* @param szTitle
|
|
|
|
* Title for the balloon notification.
|
|
|
|
* @param szInfo
|
|
|
|
* Main content for the balloon notification.
|
|
|
|
* @param uId
|
|
|
|
* Represents the particular notification icon.
|
|
|
|
*
|
|
|
|
* @return The error code.
|
|
|
|
*
|
|
|
|
*--*/
|
|
|
|
HRESULT NotifyBalloon(CSysTray* pSysTray, LPCWSTR szTitle = NULL, LPCWSTR szInfo = NULL, UINT uId = ID_ICON_HOTPLUG)
|
|
|
|
{
|
2018-02-04 01:23:28 +00:00
|
|
|
NOTIFYICONDATA nim = { 0 };
|
2018-02-04 16:21:58 +00:00
|
|
|
|
|
|
|
nim.cbSize = sizeof(nim);
|
2017-10-16 14:11:10 +00:00
|
|
|
nim.uID = uId;
|
|
|
|
nim.hWnd = pSysTray->GetHWnd();
|
|
|
|
|
|
|
|
nim.uFlags = NIF_INFO;
|
|
|
|
nim.uTimeout = 10;
|
|
|
|
nim.dwInfoFlags = NIIF_INFO;
|
|
|
|
|
|
|
|
StringCchCopy(nim.szInfoTitle, _countof(nim.szInfoTitle), szTitle);
|
|
|
|
StringCchCopy(nim.szInfo, _countof(nim.szInfo), szInfo);
|
|
|
|
BOOL ret = Shell_NotifyIcon(NIM_MODIFY, &nim);
|
|
|
|
|
|
|
|
Sleep(10000); /* As per windows, the balloon notification remains visible for atleast 10 sec.
|
|
|
|
This timer maintains the same condition.
|
|
|
|
Also it is required so that the icon doesn't hide instantly after last device is removed,
|
|
|
|
as that will prevent popping of notification.
|
|
|
|
*/
|
|
|
|
StringCchCopy(nim.szInfoTitle, _countof(nim.szInfoTitle), L"");
|
|
|
|
StringCchCopy(nim.szInfo, _countof(nim.szInfo), L"");
|
|
|
|
ret = Shell_NotifyIcon(NIM_MODIFY, &nim);
|
|
|
|
g_IsRemoving = FALSE; /* This flag is used to prevent instant icon hiding after last device is removed.
|
|
|
|
The above timer maintains the required state for the same.
|
|
|
|
*/
|
|
|
|
return ret ? S_OK : E_FAIL;
|
|
|
|
}
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE Hotplug_Init(_In_ CSysTray * pSysTray)
|
2020-03-21 22:46:24 +00:00
|
|
|
{
|
2017-10-16 14:11:10 +00:00
|
|
|
TRACE("Hotplug_Init\n");
|
2020-03-21 22:46:24 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
g_hIconHotplug = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_HOTPLUG_OK));
|
2020-03-22 10:31:56 +00:00
|
|
|
g_strHotplugTooltip.LoadStringW(IDS_HOTPLUG_REMOVE_1);
|
2020-03-21 22:46:24 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
EnumHotpluggedDevices(g_devList);
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2020-03-21 22:46:24 +00:00
|
|
|
if (g_devList.GetSize() > 0)
|
2020-03-22 10:31:56 +00:00
|
|
|
return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_HOTPLUG, g_hIconHotplug, g_strHotplugTooltip);
|
2020-03-21 22:46:24 +00:00
|
|
|
else
|
2020-03-22 10:31:56 +00:00
|
|
|
return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_HOTPLUG, g_hIconHotplug, g_strHotplugTooltip, NIS_HIDDEN);
|
2017-08-18 14:49:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE Hotplug_Update(_In_ CSysTray * pSysTray)
|
|
|
|
{
|
|
|
|
TRACE("Hotplug_Update\n");
|
2020-03-21 22:46:24 +00:00
|
|
|
return S_OK;
|
2017-08-18 14:49:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE Hotplug_Shutdown(_In_ CSysTray * pSysTray)
|
|
|
|
{
|
|
|
|
TRACE("Hotplug_Shutdown\n");
|
|
|
|
|
2020-03-21 22:46:24 +00:00
|
|
|
DestroyIcon(g_hIconHotplug);
|
|
|
|
g_hIconHotplug = NULL;
|
|
|
|
|
2017-08-18 14:49:11 +00:00
|
|
|
return pSysTray->NotifyIcon(NIM_DELETE, ID_ICON_HOTPLUG, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
static void _RunHotplug(CSysTray * pSysTray)
|
2017-08-18 14:49:11 +00:00
|
|
|
{
|
2019-08-15 20:21:21 +00:00
|
|
|
ShellExecuteW(pSysTray->GetHWnd(),
|
|
|
|
L"open",
|
|
|
|
L"rundll32.exe",
|
|
|
|
L"shell32.dll,Control_RunDLL hotplug.dll",
|
|
|
|
NULL,
|
|
|
|
SW_SHOWNORMAL);
|
2017-08-18 14:49:11 +00:00
|
|
|
}
|
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
static void _ShowContextMenu(CSysTray * pSysTray)
|
2017-08-18 14:49:11 +00:00
|
|
|
{
|
2017-10-16 14:11:10 +00:00
|
|
|
HMENU hPopup = CreatePopupMenu();
|
|
|
|
ULONG ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR);
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
for (INT index = 0; index < g_devList.GetSize(); index++)
|
|
|
|
{
|
2020-03-22 10:31:56 +00:00
|
|
|
WCHAR dispName[DISPLAY_NAME_LEN];
|
|
|
|
CString menuName;
|
2017-10-16 14:11:10 +00:00
|
|
|
CONFIGRET cr = CM_Get_DevNode_Registry_Property(g_devList[index], CM_DRP_DEVICEDESC, NULL, dispName, &ulLength, 0);
|
|
|
|
if (cr != CR_SUCCESS)
|
|
|
|
StrCpyW(dispName, L"Unknown Device");
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2020-03-22 10:31:56 +00:00
|
|
|
menuName.Format(IDS_HOTPLUG_REMOVE_3, dispName);
|
2017-10-16 14:11:10 +00:00
|
|
|
AppendMenuW(hPopup, MF_STRING, index+1, menuName);
|
|
|
|
}
|
2017-08-18 14:49:11 +00:00
|
|
|
|
|
|
|
SetForegroundWindow(pSysTray->GetHWnd());
|
2017-10-16 14:11:10 +00:00
|
|
|
DWORD flags = TPM_RETURNCMD | TPM_NONOTIFY | TPM_RIGHTALIGN | TPM_BOTTOMALIGN;
|
|
|
|
POINT pt;
|
|
|
|
GetCursorPos(&pt);
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
DWORD id = TrackPopupMenuEx(hPopup, flags,
|
|
|
|
pt.x, pt.y,
|
|
|
|
pSysTray->GetHWnd(), NULL);
|
|
|
|
|
|
|
|
if (id > 0)
|
|
|
|
{
|
|
|
|
id--; // since array indices starts from zero.
|
|
|
|
CONFIGRET cr = CM_Get_DevNode_Registry_Property(g_devList[id], CM_DRP_DEVICEDESC, NULL, g_strMenuSel, &ulLength, 0);
|
|
|
|
if (cr != CR_SUCCESS)
|
|
|
|
StrCpyW(g_strMenuSel, L"Unknown Device");
|
|
|
|
|
|
|
|
cr = CM_Request_Device_Eject_Ex(g_devList[id], 0, 0, 0, 0, 0);
|
|
|
|
if (cr != CR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR strInfo[128];
|
|
|
|
swprintf(strInfo, L"Problem Ejecting %wS", g_strMenuSel);
|
2020-04-01 09:42:24 +00:00
|
|
|
MessageBox(0, L"The device cannot be stopped right now! Try stopping it again later!", strInfo, MB_OK | MB_ICONEXCLAMATION);
|
2017-10-16 14:11:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-01 09:42:24 +00:00
|
|
|
//MessageBox(0, L"Device ejected successfully!! You can safely remove the device now!", L"Safely Remove Hardware", MB_OK | MB_ICONINFORMATION);
|
2017-10-16 14:11:10 +00:00
|
|
|
g_IsRemoving = TRUE;
|
|
|
|
g_devList.RemoveAt(id); /* thing is.. even after removing id at this point, the devnode_change occurs after some seconds of sucessful removal
|
|
|
|
and since pendrive is still plugged in it gets enumerated, if problem number is not filtered.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
DestroyMenu(hPopup);
|
2017-08-18 14:49:11 +00:00
|
|
|
}
|
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
static void _ShowContextMenuR(CSysTray * pSysTray)
|
2017-08-18 14:49:11 +00:00
|
|
|
{
|
2017-10-16 14:11:10 +00:00
|
|
|
CString strMenu((LPWSTR)IDS_HOTPLUG_REMOVE_2);
|
2017-08-18 14:49:11 +00:00
|
|
|
HMENU hPopup = CreatePopupMenu();
|
2017-10-16 14:11:10 +00:00
|
|
|
AppendMenuW(hPopup, MF_STRING, IDS_HOTPLUG_REMOVE_2, strMenu);
|
2019-04-22 08:36:17 +00:00
|
|
|
SetMenuDefaultItem(hPopup, IDS_HOTPLUG_REMOVE_2, FALSE);
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
SetForegroundWindow(pSysTray->GetHWnd());
|
|
|
|
DWORD flags = TPM_RETURNCMD | TPM_NONOTIFY | TPM_RIGHTALIGN | TPM_BOTTOMALIGN;
|
|
|
|
POINT pt;
|
|
|
|
GetCursorPos(&pt);
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
DWORD id = TrackPopupMenuEx(hPopup, flags,
|
|
|
|
pt.x, pt.y,
|
|
|
|
pSysTray->GetHWnd(), NULL);
|
2017-08-18 14:49:11 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
if (id == IDS_HOTPLUG_REMOVE_2)
|
2017-08-18 14:49:11 +00:00
|
|
|
{
|
2017-10-16 14:11:10 +00:00
|
|
|
_RunHotplug(pSysTray);
|
2017-08-18 14:49:11 +00:00
|
|
|
}
|
2017-10-16 14:11:10 +00:00
|
|
|
|
|
|
|
DestroyMenu(hPopup);
|
2017-08-18 14:49:11 +00:00
|
|
|
}
|
|
|
|
|
2020-03-21 22:46:24 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
HotplugDeviceTimer(
|
|
|
|
_In_ CSysTray *pSysTray)
|
|
|
|
{
|
|
|
|
TRACE("HotplugDeviceTimer()\n");
|
|
|
|
|
|
|
|
EnumHotpluggedDevices(g_devList);
|
|
|
|
|
|
|
|
if (g_devList.GetSize() > 0)
|
2020-03-22 10:31:56 +00:00
|
|
|
pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strHotplugTooltip);
|
2020-03-21 22:46:24 +00:00
|
|
|
else
|
2020-03-22 10:31:56 +00:00
|
|
|
pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strHotplugTooltip, NIS_HIDDEN);
|
2020-03-21 22:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE Hotplug_Message(_In_ CSysTray * pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
|
2017-08-18 14:49:11 +00:00
|
|
|
{
|
|
|
|
TRACE("Hotplug_Message uMsg=%d, wParam=%x, lParam=%x\n", uMsg, wParam, lParam);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_USER + 220:
|
|
|
|
TRACE("Hotplug_Message: WM_USER+220\n");
|
2019-04-22 22:12:23 +00:00
|
|
|
if (wParam == HOTPLUG_SERVICE_FLAG)
|
2017-08-18 14:49:11 +00:00
|
|
|
{
|
2019-04-22 22:12:23 +00:00
|
|
|
if (lParam)
|
|
|
|
{
|
|
|
|
pSysTray->EnableService(HOTPLUG_SERVICE_FLAG, TRUE);
|
2017-08-18 14:49:11 +00:00
|
|
|
return Hotplug_Init(pSysTray);
|
2019-04-22 22:12:23 +00:00
|
|
|
}
|
2017-08-18 14:49:11 +00:00
|
|
|
else
|
2019-04-22 22:12:23 +00:00
|
|
|
{
|
|
|
|
pSysTray->EnableService(HOTPLUG_SERVICE_FLAG, FALSE);
|
2017-08-18 14:49:11 +00:00
|
|
|
return Hotplug_Shutdown(pSysTray);
|
2019-04-22 22:12:23 +00:00
|
|
|
}
|
2017-08-18 14:49:11 +00:00
|
|
|
}
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
case WM_USER + 221:
|
|
|
|
TRACE("Hotplug_Message: WM_USER+221\n");
|
2019-04-22 22:12:23 +00:00
|
|
|
if (wParam == HOTPLUG_SERVICE_FLAG)
|
2017-08-18 14:49:11 +00:00
|
|
|
{
|
2019-04-22 22:12:23 +00:00
|
|
|
lResult = (LRESULT)pSysTray->IsServiceEnabled(HOTPLUG_SERVICE_FLAG);
|
2017-08-18 14:49:11 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return S_FALSE;
|
|
|
|
|
2018-02-28 19:29:29 +00:00
|
|
|
case WM_TIMER:
|
|
|
|
if (wParam == HOTPLUG_TIMER_ID)
|
|
|
|
{
|
|
|
|
KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
|
|
|
|
_ShowContextMenu(pSysTray);
|
|
|
|
}
|
2020-03-21 22:46:24 +00:00
|
|
|
else if (wParam == HOTPLUG_DEVICE_TIMER_ID)
|
|
|
|
{
|
|
|
|
KillTimer(pSysTray->GetHWnd(), HOTPLUG_DEVICE_TIMER_ID);
|
|
|
|
HotplugDeviceTimer(pSysTray);
|
|
|
|
}
|
2018-02-28 19:29:29 +00:00
|
|
|
break;
|
|
|
|
|
2017-08-18 14:49:11 +00:00
|
|
|
case ID_ICON_HOTPLUG:
|
|
|
|
switch (lParam)
|
|
|
|
{
|
|
|
|
case WM_LBUTTONDOWN:
|
2018-03-06 19:41:28 +00:00
|
|
|
SetTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID, GetDoubleClickTime(), NULL);
|
2017-08-18 14:49:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONDBLCLK:
|
2018-02-28 19:29:29 +00:00
|
|
|
KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
|
2017-10-16 14:11:10 +00:00
|
|
|
_RunHotplug(pSysTray);
|
2017-08-18 14:49:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONUP:
|
2017-10-16 14:11:10 +00:00
|
|
|
_ShowContextMenuR(pSysTray);
|
2017-08-18 14:49:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDBLCLK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
case WM_DEVICECHANGE:
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case DBT_DEVNODES_CHANGED:
|
2020-03-21 22:46:24 +00:00
|
|
|
TRACE("WM_DEVICECHANGE : DBT_DEVNODES_CHANGED\n");
|
|
|
|
SetTimer(pSysTray->GetHWnd(), HOTPLUG_DEVICE_TIMER_ID, 100, NULL);
|
2017-10-16 14:11:10 +00:00
|
|
|
lResult = true;
|
|
|
|
break;
|
2020-03-21 22:46:24 +00:00
|
|
|
|
2017-10-16 14:11:10 +00:00
|
|
|
case DBT_DEVICEARRIVAL:
|
|
|
|
break;
|
|
|
|
case DBT_DEVICEQUERYREMOVE:
|
|
|
|
break;
|
|
|
|
case DBT_DEVICEQUERYREMOVEFAILED:
|
|
|
|
break;
|
|
|
|
case DBT_DEVICEREMOVECOMPLETE:
|
|
|
|
WCHAR strInfo[128];
|
|
|
|
swprintf(strInfo, L"The %wS can now be safely removed from the system.", g_strMenuSel);
|
|
|
|
NotifyBalloon(pSysTray, L"Safe to Remove Hardware", strInfo);
|
|
|
|
|
|
|
|
lResult = true;
|
|
|
|
break;
|
|
|
|
case DBT_DEVICEREMOVEPENDING:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
|
2017-08-18 14:49:11 +00:00
|
|
|
default:
|
|
|
|
TRACE("Hotplug_Message received for unknown ID %d, ignoring.\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|