Author: gedmurphy Date: Wed Nov 26 19:46:26 2014 New Revision: 65495
URL: http://svn.reactos.org/svn/reactos?rev=65495&view=rev Log: [DEVICE_MANAGER] - On refresh, recurse the tree and delete all the Device Ids attached to each node - Fix SAL and a few missing comments
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.h trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp [iso-8859-1] Wed Nov 26 19:46:26 2014 @@ -95,6 +95,8 @@ BOOL CDeviceView::Uninitialize() { + EmptyDeviceView(); + (VOID)m_Devices->Uninitialize();
return TRUE; @@ -186,12 +188,8 @@ { 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 @@
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); +}
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h [iso-8859-1] Wed Nov 26 19:46:26 2014 @@ -81,5 +81,12 @@ _In_ INT DevImage, _In_ UINT OverlayImage ); + + VOID RecurseDeviceView( + _In_ HTREEITEM hParentItem + ); + + VOID EmptyDeviceView( + ); };
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp [iso-8859-1] Wed Nov 26 19:46:26 2014 @@ -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 @@ _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 @@
*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 @@ } }
+ /* Make sure we got the string */ if (*DeviceId == NULL) return FALSE;
@@ -180,8 +185,10 @@ 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 @@ *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 @@
}
+ /* Cleanup if something failed */ if (cr != CR_SUCCESS) { HeapFree(GetProcessHeap(), 0, *DeviceId); @@ -346,7 +353,7 @@ _Out_ LPBOOL MoreItems, _Out_ LPTSTR DeviceName, _In_ DWORD DeviceNameSize, - _Out_ LPTSTR *DeviceId + _Outptr_ LPTSTR *DeviceId ) { SP_DEVINFO_DATA DeviceInfoData;
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.h [iso-8859-1] Wed Nov 26 19:46:26 2014 @@ -42,7 +42,7 @@ _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 @@ _Out_ LPBOOL MoreItems, _Out_writes_(DeviceNameSize) LPTSTR DeviceName, _In_ DWORD DeviceNameSize, - _Out_ LPTSTR *DeviceId + _Outptr_ LPTSTR *DeviceId );
BOOL GetDeviceStatus(
Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln [iso-8859-1] Wed Nov 26 19:46:26 2014 @@ -26,7 +26,4 @@ GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection EndGlobal