Author: gedmurphy Date: Mon Dec 21 15:25:54 2009 New Revision: 44681
URL: http://svn.reactos.org/svn/reactos?rev=44681&view=rev Log: Recurse the tree and clean up all the strings tagged to the items. Servman now has working dependency tracking
Modified: trunk/reactos/base/applications/mscutils/servman/propsheet_depends.c
Modified: trunk/reactos/base/applications/mscutils/servman/propsheet_depends.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/propsheet_depends.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/servman/propsheet_depends.c [iso-8859-1] Mon Dec 21 15:25:54 2009 @@ -27,8 +27,9 @@ tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_CHILDREN; tvi.pszText = lpDisplayName; tvi.cchTextMax = _tcslen(lpDisplayName); - tvi.cChildren = bHasChildren; //I_CHILDRENCALLBACK; - + tvi.cChildren = bHasChildren; + + /* Select the image for this service */ switch (ServiceType) { case SERVICE_WIN32_OWN_PROCESS: @@ -49,13 +50,16 @@ break; }
- /* Attach the service name */ - tvi.lParam = (LPARAM)(LPTSTR)HeapAlloc(GetProcessHeap(), - 0, - (_tcslen(lpServiceName) + 1) * sizeof(TCHAR)); - if (tvi.lParam) - { - _tcscpy((LPTSTR)tvi.lParam, lpServiceName); + if (lpServiceName) + { + /* Attach the service name */ + tvi.lParam = (LPARAM)(LPTSTR)HeapAlloc(GetProcessHeap(), + 0, + (_tcslen(lpServiceName) + 1) * sizeof(TCHAR)); + if (tvi.lParam) + { + _tcscpy((LPTSTR)tvi.lParam, lpServiceName); + } }
tvins.item = tvi; @@ -64,10 +68,73 @@ return TreeView_InsertItem(hTreeView, &tvins); }
+static LPARAM +TreeView_GetItemParam(HWND hTreeView, + HTREEITEM hItem) +{ + LPARAM lParam = 0; + TVITEM tv = {0}; + + tv.mask = TVIF_PARAM | TVIF_HANDLE; + tv.hItem = hItem; + + if (TreeView_GetItem(hTreeView, &tv)) + { + lParam = tv.lParam; + } + + return lParam; +} + +static VOID +DestroyItem(HWND hTreeView, + HTREEITEM hItem) +{ + HTREEITEM hChildItem; + LPTSTR lpServiceName; + + /* Does this item have any children */ + hChildItem = TreeView_GetChild(hTreeView, hItem); + if (hChildItem) + { + /* It does, recurse to that one */ + DestroyItem(hTreeView, hChildItem); + } + + /* Get the string and free it */ + lpServiceName = (LPTSTR)TreeView_GetItemParam(hTreeView, hItem); + if (lpServiceName) + { + HeapFree(GetProcessHeap(), + 0, + lpServiceName); + } +} + static VOID DestroyTreeView(HWND hTreeView) { - //FIXME: traverse the nodes and free the strings + HTREEITEM hItem; + + /* Get the first item in the top level */ + hItem = TreeView_GetFirstVisible(hTreeView); + if (hItem) + { + /* Kill it and all children */ + DestroyItem(hTreeView, hItem); + + /* Kill all remaining top level items */ + while (hItem) + { + /* Are there any more items at the top level */ + hItem = TreeView_GetNextSibling(hTreeView, hItem); + if (hItem) + { + /* Kill it and all children */ + DestroyItem(hTreeView, hItem); + } + } + } }
/* @@ -85,25 +152,6 @@ tv.cchTextMax = (int)cbBuffer;
return TreeView_GetItem(hTreeView, &tv); -} - - -static LPARAM -TreeView_GetItemParam(HWND hTreeView, - HTREEITEM hItem) -{ - LPARAM lParam = 0; - TVITEM tv = {0}; - - tv.mask = TVIF_PARAM | TVIF_HANDLE; - tv.hItem = hItem; - - if (TreeView_GetItem(hTreeView, &tv)) - { - lParam = tv.lParam; - } - - return lParam; } */