VOID TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPTSTR lpServiceName) { LPENUM_SERVICE_STATUSW lpServiceStatus; LPTSTR lpNoDepends; DWORD count, i; BOOL bHasChildren; /* Get a list of service dependents */ lpServiceStatus = TV2_GetDependants(lpServiceName, &count); if (lpServiceStatus) { for (i = 0; i < count; i++) { /* Does this item need a +/- box? */ bHasChildren = TV2_HasDependantServices(lpServiceStatus[i].lpServiceName); /* Add it */ AddItemToTreeView(pDlgInfo->hDependsTreeView2, hParent, lpServiceStatus[i].lpDisplayName, lpServiceStatus[i].lpServiceName, lpServiceStatus[i].ServiceStatus.dwServiceType, bHasChildren); } HeapFree(GetProcessHeap(), 0, lpServiceStatus); } else { /* If there is no parent, set the tree to 'no dependencies' */ if (!hParent) { /* Load the 'No dependencies' string */ AllocAndLoadString(&lpNoDepends, hInstance, IDS_NO_DEPENDS); AddItemToTreeView(pDlgInfo->hDependsTreeView2, NULL, lpNoDepends, NULL, 0, FALSE); HeapFree(ProcessHeap, 0, lpNoDepends); /* Disable the window */ EnableWindow(pDlgInfo->hDependsTreeView2, FALSE); } } }
static BOOL BuildListOfServicesToStop(LPWSTR *lpServiceList, LPWSTR lpServiceName) { LPENUM_SERVICE_STATUS lpServiceStatus; DWORD dwCount, i; BOOL bRet = FALSE; /* Get a list of service dependents */ lpServiceStatus = TV2_GetDependants(lpServiceName, &dwCount); if (lpServiceStatus) { for (i = 0; i < dwCount; i++) { /* Does this service need stopping? */ if (lpServiceStatus[i].ServiceStatus.dwCurrentState != SERVICE_STOPPED && lpServiceStatus[i].ServiceStatus.dwCurrentState != SERVICE_STOP_PENDING) { /* Does this service have any dependents? */ if (TV2_HasDependantServices(lpServiceStatus[i].lpServiceName)) { /* recall this function with the dependent */ BuildListOfServicesToStop(lpServiceList, lpServiceStatus[i].lpServiceName); } /* Add the service to the list */ *lpServiceList = AddServiceToList(lpServiceList, lpServiceStatus[i].lpServiceName); /* We've got one */ bRet = TRUE; } } HeapFree(GetProcessHeap(), 0, lpServiceStatus); } return bRet; }