mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[STOBJECT] Remove obsolete code and use string resources instead of hard-coded strings
This commit is contained in:
parent
78098f99e0
commit
01fd69dfe2
1 changed files with 13 additions and 42 deletions
|
@ -15,12 +15,9 @@
|
||||||
|
|
||||||
#define DISPLAY_NAME_LEN 40
|
#define DISPLAY_NAME_LEN 40
|
||||||
|
|
||||||
//BOOL WINAPI UnregisterDeviceNotification(HDEVNOTIFY Handle);
|
|
||||||
|
|
||||||
CSimpleArray<DEVINST> g_devList;
|
CSimpleArray<DEVINST> g_devList;
|
||||||
/*static HDEVNOTIFY g_hDevNotify = NULL;*/
|
CString g_strHotplugTooltip;
|
||||||
static HICON g_hIconHotplug = NULL;
|
static HICON g_hIconHotplug = NULL;
|
||||||
static LPCWSTR g_strTooltip = L"Safely Remove Hardware and Eject Media";
|
|
||||||
static WCHAR g_strMenuSel[DISPLAY_NAME_LEN];
|
static WCHAR g_strMenuSel[DISPLAY_NAME_LEN];
|
||||||
static BOOL g_IsRemoving = FALSE;
|
static BOOL g_IsRemoving = FALSE;
|
||||||
|
|
||||||
|
@ -48,14 +45,11 @@ HRESULT EnumHotpluggedDevices(CSimpleArray<DEVINST> &devList)
|
||||||
for (int idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++)
|
for (int idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++)
|
||||||
{
|
{
|
||||||
DWORD dwCapabilities = 0, dwSize = sizeof(dwCapabilities);
|
DWORD dwCapabilities = 0, dwSize = sizeof(dwCapabilities);
|
||||||
WCHAR dispName[DISPLAY_NAME_LEN];
|
ULONG ulStatus = 0, ulProblem = 0;
|
||||||
ULONG ulStatus = 0, ulPnum = 0, ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR);
|
CONFIGRET cr = CM_Get_DevNode_Status(&ulStatus, &ulProblem, did.DevInst, 0);
|
||||||
CONFIGRET cr = CM_Get_DevNode_Status(&ulStatus, &ulPnum, did.DevInst, 0);
|
|
||||||
if (cr != CR_SUCCESS)
|
|
||||||
continue;
|
|
||||||
cr = CM_Get_DevNode_Registry_Property(did.DevInst, CM_DRP_DEVICEDESC, NULL, dispName, &ulLength, 0);
|
|
||||||
if (cr != CR_SUCCESS)
|
if (cr != CR_SUCCESS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cr = CM_Get_DevNode_Registry_Property(did.DevInst, CM_DRP_CAPABILITIES, NULL, &dwCapabilities, &dwSize, 0);
|
cr = CM_Get_DevNode_Registry_Property(did.DevInst, CM_DRP_CAPABILITIES, NULL, &dwCapabilities, &dwSize, 0);
|
||||||
if (cr != CR_SUCCESS)
|
if (cr != CR_SUCCESS)
|
||||||
continue;
|
continue;
|
||||||
|
@ -65,7 +59,7 @@ HRESULT EnumHotpluggedDevices(CSimpleArray<DEVINST> &devList)
|
||||||
!(dwCapabilities & CM_DEVCAP_DOCKDEVICE) &&
|
!(dwCapabilities & CM_DEVCAP_DOCKDEVICE) &&
|
||||||
!(dwCapabilities & CM_DEVCAP_SURPRISEREMOVALOK) &&
|
!(dwCapabilities & CM_DEVCAP_SURPRISEREMOVALOK) &&
|
||||||
((dwCapabilities & CM_DEVCAP_EJECTSUPPORTED) || (ulStatus & DN_DISABLEABLE)) &&
|
((dwCapabilities & CM_DEVCAP_EJECTSUPPORTED) || (ulStatus & DN_DISABLEABLE)) &&
|
||||||
!ulPnum)
|
!ulProblem)
|
||||||
{
|
{
|
||||||
devList.Add(did.DevInst);
|
devList.Add(did.DevInst);
|
||||||
}
|
}
|
||||||
|
@ -132,13 +126,14 @@ HRESULT STDMETHODCALLTYPE Hotplug_Init(_In_ CSysTray * pSysTray)
|
||||||
TRACE("Hotplug_Init\n");
|
TRACE("Hotplug_Init\n");
|
||||||
|
|
||||||
g_hIconHotplug = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_HOTPLUG_OK));
|
g_hIconHotplug = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_HOTPLUG_OK));
|
||||||
|
g_strHotplugTooltip.LoadStringW(IDS_HOTPLUG_REMOVE_1);
|
||||||
|
|
||||||
EnumHotpluggedDevices(g_devList);
|
EnumHotpluggedDevices(g_devList);
|
||||||
|
|
||||||
if (g_devList.GetSize() > 0)
|
if (g_devList.GetSize() > 0)
|
||||||
return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip);
|
return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_HOTPLUG, g_hIconHotplug, g_strHotplugTooltip);
|
||||||
else
|
else
|
||||||
return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip, NIS_HIDDEN);
|
return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_HOTPLUG, g_hIconHotplug, g_strHotplugTooltip, NIS_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE Hotplug_Update(_In_ CSysTray * pSysTray)
|
HRESULT STDMETHODCALLTYPE Hotplug_Update(_In_ CSysTray * pSysTray)
|
||||||
|
@ -174,12 +169,13 @@ static void _ShowContextMenu(CSysTray * pSysTray)
|
||||||
|
|
||||||
for (INT index = 0; index < g_devList.GetSize(); index++)
|
for (INT index = 0; index < g_devList.GetSize(); index++)
|
||||||
{
|
{
|
||||||
WCHAR dispName[DISPLAY_NAME_LEN], menuName[DISPLAY_NAME_LEN + 10];
|
WCHAR dispName[DISPLAY_NAME_LEN];
|
||||||
|
CString menuName;
|
||||||
CONFIGRET cr = CM_Get_DevNode_Registry_Property(g_devList[index], CM_DRP_DEVICEDESC, NULL, dispName, &ulLength, 0);
|
CONFIGRET cr = CM_Get_DevNode_Registry_Property(g_devList[index], CM_DRP_DEVICEDESC, NULL, dispName, &ulLength, 0);
|
||||||
if (cr != CR_SUCCESS)
|
if (cr != CR_SUCCESS)
|
||||||
StrCpyW(dispName, L"Unknown Device");
|
StrCpyW(dispName, L"Unknown Device");
|
||||||
|
|
||||||
swprintf(menuName, L"Eject %wS", dispName);
|
menuName.Format(IDS_HOTPLUG_REMOVE_3, dispName);
|
||||||
AppendMenuW(hPopup, MF_STRING, index+1, menuName);
|
AppendMenuW(hPopup, MF_STRING, index+1, menuName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,9 +249,9 @@ HotplugDeviceTimer(
|
||||||
EnumHotpluggedDevices(g_devList);
|
EnumHotpluggedDevices(g_devList);
|
||||||
|
|
||||||
if (g_devList.GetSize() > 0)
|
if (g_devList.GetSize() > 0)
|
||||||
pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip);
|
pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strHotplugTooltip);
|
||||||
else
|
else
|
||||||
pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip, NIS_HIDDEN);
|
pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strHotplugTooltip, NIS_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,22 +261,6 @@ HRESULT STDMETHODCALLTYPE Hotplug_Message(_In_ CSysTray * pSysTray, UINT uMsg, W
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
/*case WM_CREATE:
|
|
||||||
TRACE("Hotplug_Message: WM_CREATE\n");
|
|
||||||
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;
|
|
||||||
|
|
||||||
ZeroMemory(&NotificationFilter, sizeof(NotificationFilter));
|
|
||||||
NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
|
|
||||||
NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
|
||||||
|
|
||||||
g_hDevNotify = RegisterDeviceNotification(pSysTray->GetHWnd(), &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
|
|
||||||
if (g_hDevNotify != NULL)
|
|
||||||
{
|
|
||||||
lResult = true;
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
return S_FALSE;*/
|
|
||||||
|
|
||||||
case WM_USER + 220:
|
case WM_USER + 220:
|
||||||
TRACE("Hotplug_Message: WM_USER+220\n");
|
TRACE("Hotplug_Message: WM_USER+220\n");
|
||||||
if (wParam == HOTPLUG_SERVICE_FLAG)
|
if (wParam == HOTPLUG_SERVICE_FLAG)
|
||||||
|
@ -321,8 +301,6 @@ HRESULT STDMETHODCALLTYPE Hotplug_Message(_In_ CSysTray * pSysTray, UINT uMsg, W
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ICON_HOTPLUG:
|
case ID_ICON_HOTPLUG:
|
||||||
Hotplug_Update(pSysTray);
|
|
||||||
|
|
||||||
switch (lParam)
|
switch (lParam)
|
||||||
{
|
{
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
|
@ -379,13 +357,6 @@ HRESULT STDMETHODCALLTYPE Hotplug_Message(_In_ CSysTray * pSysTray, UINT uMsg, W
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
/*case WM_CLOSE:
|
|
||||||
if (!UnregisterDeviceNotification(hDeviceNotify))
|
|
||||||
{
|
|
||||||
return S_FALSE;
|
|
||||||
}
|
|
||||||
return S_OK;*/
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
TRACE("Hotplug_Message received for unknown ID %d, ignoring.\n");
|
TRACE("Hotplug_Message received for unknown ID %d, ignoring.\n");
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
Loading…
Reference in a new issue