mirror of
https://github.com/reactos/reactos.git
synced 2024-08-01 09:01:13 +00:00
[DEVICE_MANAGER]
- On refresh, recurse the tree and delete all the Device Ids attached to each node - Fix SAL and a few missing comments svn path=/trunk/; revision=65495
This commit is contained in:
parent
552b2ba55c
commit
d006975972
|
@ -95,6 +95,8 @@ CDeviceView::Initialize()
|
|||
BOOL
|
||||
CDeviceView::Uninitialize()
|
||||
{
|
||||
EmptyDeviceView();
|
||||
|
||||
(VOID)m_Devices->Uninitialize();
|
||||
|
||||
return TRUE;
|
||||
|
@ -186,12 +188,8 @@ unsigned int __stdcall CDeviceView::ListDevicesThread(void *Param)
|
|||
{
|
||||
CDeviceView *This = (CDeviceView *)Param;
|
||||
|
||||
/* Check if there are any items in the tree */
|
||||
if (TreeView_GetRoot(This->m_hTreeView) != NULL)
|
||||
{
|
||||
/* Delete all the items */
|
||||
(VOID)TreeView_DeleteAllItems(This->m_hTreeView);
|
||||
}
|
||||
/* Clear any existing data */
|
||||
This->EmptyDeviceView();
|
||||
|
||||
/* Reset the tree root */
|
||||
This->m_hTreeRoot = NULL;
|
||||
|
@ -515,3 +513,66 @@ CDeviceView::InsertIntoTreeView(
|
|||
|
||||
return TreeView_InsertItem(m_hTreeView, &tvins);
|
||||
}
|
||||
|
||||
VOID
|
||||
CDeviceView::RecurseDeviceView(
|
||||
_In_ HTREEITEM hParentItem
|
||||
)
|
||||
{
|
||||
HTREEITEM hItem;
|
||||
TVITEMW tvItem;
|
||||
|
||||
/* Check if this node has any children */
|
||||
hItem = TreeView_GetChild(m_hTreeView, hParentItem);
|
||||
if (hItem == NULL) return;
|
||||
|
||||
/* The lParam contains the device id */
|
||||
tvItem.hItem = hItem;
|
||||
tvItem.mask = TVIF_PARAM;
|
||||
|
||||
if (TreeView_GetItem(m_hTreeView, &tvItem) &&
|
||||
tvItem.lParam != NULL)
|
||||
{
|
||||
/* Free the device id */
|
||||
HeapFree(GetProcessHeap(), 0, (LPVOID)tvItem.lParam);
|
||||
}
|
||||
|
||||
/* This node may have its own children */
|
||||
RecurseDeviceView(hItem);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Get the next item at this level */
|
||||
hItem = TreeView_GetNextSibling(m_hTreeView, hItem);
|
||||
if (hItem == NULL) break;
|
||||
|
||||
tvItem.hItem = hItem;
|
||||
tvItem.mask = TVIF_PARAM;
|
||||
|
||||
if (TreeView_GetItem(m_hTreeView, &tvItem))
|
||||
{
|
||||
if (tvItem.lParam != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, (LPVOID)tvItem.lParam);
|
||||
}
|
||||
|
||||
/* This node may have its own children */
|
||||
RecurseDeviceView(hItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
CDeviceView::EmptyDeviceView()
|
||||
{
|
||||
HTREEITEM hItem;
|
||||
|
||||
/* Check if there are any items in the tree */
|
||||
hItem = TreeView_GetRoot(m_hTreeView);
|
||||
if (hItem == NULL) return;
|
||||
|
||||
/* Free all the Device Ids */
|
||||
RecurseDeviceView(hItem);
|
||||
|
||||
/* Delete all the items */
|
||||
(VOID)TreeView_DeleteAllItems(m_hTreeView);
|
||||
}
|
|
@ -81,5 +81,12 @@ private:
|
|||
_In_ INT DevImage,
|
||||
_In_ UINT OverlayImage
|
||||
);
|
||||
|
||||
VOID RecurseDeviceView(
|
||||
_In_ HTREEITEM hParentItem
|
||||
);
|
||||
|
||||
VOID EmptyDeviceView(
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include "devmgmt.h"
|
||||
#include "Devices.h"
|
||||
|
||||
|
||||
/* PUBLIC METHODS *****************************************/
|
||||
|
||||
CDevices::CDevices(void) :
|
||||
m_bInitialized(FALSE),
|
||||
m_RootImageIndex(-1)
|
||||
|
@ -133,7 +136,7 @@ CDevices::GetDevice(
|
|||
_In_ DEVINST Device,
|
||||
_Out_writes_(DeviceNameSize) LPWSTR DeviceName,
|
||||
_In_ DWORD DeviceNameSize,
|
||||
_Out_ LPWSTR *DeviceId,
|
||||
_Outptr_ LPWSTR *DeviceId,
|
||||
_Out_ PINT ClassImage,
|
||||
_Out_ LPBOOL IsUnknown,
|
||||
_Out_ LPBOOL IsHidden
|
||||
|
@ -146,6 +149,7 @@ CDevices::GetDevice(
|
|||
|
||||
*DeviceId = NULL;
|
||||
|
||||
/* Get the length of the device id string */
|
||||
cr = CM_Get_Device_ID_Size(&ulLength, Device, 0);
|
||||
if (cr == CR_SUCCESS)
|
||||
{
|
||||
|
@ -166,6 +170,7 @@ CDevices::GetDevice(
|
|||
}
|
||||
}
|
||||
|
||||
/* Make sure we got the string */
|
||||
if (*DeviceId == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -180,8 +185,10 @@ CDevices::GetDevice(
|
|||
0);
|
||||
if (cr == CR_SUCCESS)
|
||||
{
|
||||
/* Convert the string to a proper guid */
|
||||
CLSIDFromString(ClassGuidString, &ClassGuid);
|
||||
|
||||
/* Check if this is a hidden device */
|
||||
if ((IsEqualGUID(ClassGuid, GUID_DEVCLASS_LEGACYDRIVER) ||
|
||||
IsEqualGUID(ClassGuid, GUID_DEVCLASS_VOLUME)))
|
||||
{
|
||||
|
@ -195,13 +202,12 @@ CDevices::GetDevice(
|
|||
*IsUnknown = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Get the image for the class this device is in */
|
||||
SetupDiGetClassImageIndex(&m_ImageListData,
|
||||
&ClassGuid,
|
||||
ClassImage);
|
||||
|
||||
|
||||
|
||||
/* Get the description for the device */
|
||||
ulLength = DeviceNameSize * sizeof(WCHAR);
|
||||
cr = CM_Get_DevNode_Registry_PropertyW(Device,
|
||||
CM_DRP_FRIENDLYNAME,
|
||||
|
@ -221,6 +227,7 @@ CDevices::GetDevice(
|
|||
|
||||
}
|
||||
|
||||
/* Cleanup if something failed */
|
||||
if (cr != CR_SUCCESS)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, *DeviceId);
|
||||
|
@ -346,7 +353,7 @@ CDevices::EnumDevicesForClass(
|
|||
_Out_ LPBOOL MoreItems,
|
||||
_Out_ LPTSTR DeviceName,
|
||||
_In_ DWORD DeviceNameSize,
|
||||
_Out_ LPTSTR *DeviceId
|
||||
_Outptr_ LPTSTR *DeviceId
|
||||
)
|
||||
{
|
||||
SP_DEVINFO_DATA DeviceInfoData;
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
_In_ DEVINST Device,
|
||||
_Out_writes_(DeviceNameSize) LPTSTR DeviceName,
|
||||
_In_ DWORD DeviceNameSize,
|
||||
_Out_ LPTSTR *DeviceId,
|
||||
_Outptr_ LPTSTR *DeviceId,
|
||||
_Out_ PINT ClassImage,
|
||||
_Out_ LPBOOL IsUnknown,
|
||||
_Out_ LPBOOL IsHidden
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
_Out_ LPBOOL MoreItems,
|
||||
_Out_writes_(DeviceNameSize) LPTSTR DeviceName,
|
||||
_In_ DWORD DeviceNameSize,
|
||||
_Out_ LPTSTR *DeviceId
|
||||
_Outptr_ LPTSTR *DeviceId
|
||||
);
|
||||
|
||||
BOOL GetDeviceStatus(
|
||||
|
|
|
@ -26,7 +26,4 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
Loading…
Reference in a new issue