mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
Add full depth of dependencies for the first tree view
svn path=/trunk/; revision=44680
This commit is contained in:
parent
710b5b318b
commit
1ebe1b0e18
4 changed files with 210 additions and 144 deletions
|
@ -80,84 +80,110 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
|
|||
return lpStr;
|
||||
}
|
||||
|
||||
static VOID
|
||||
VOID
|
||||
TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
|
||||
HTREEITEM hParent,
|
||||
SC_HANDLE hService)
|
||||
LPTSTR lpServiceName)
|
||||
{
|
||||
SC_HANDLE hSCManager;
|
||||
SC_HANDLE hService;
|
||||
LPQUERY_SERVICE_CONFIG lpServiceConfig;
|
||||
LPTSTR lpDependants;
|
||||
LPTSTR lpStr;
|
||||
LPTSTR lpNoDepends;
|
||||
BOOL bHasChildren;
|
||||
|
||||
/* Get a list of service dependents */
|
||||
lpDependants = TV1_GetDependants(pDlgInfo, hService);
|
||||
if (lpDependants)
|
||||
hSCManager = OpenSCManager(NULL,
|
||||
NULL,
|
||||
SC_MANAGER_ALL_ACCESS);
|
||||
if (hSCManager)
|
||||
{
|
||||
lpStr = lpDependants;
|
||||
|
||||
/* Make sure this isn't the end of the list */
|
||||
while (*lpStr)
|
||||
hService = OpenService(hSCManager,
|
||||
lpServiceName,
|
||||
SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
|
||||
if (hService)
|
||||
{
|
||||
/* Get the info for this service */
|
||||
lpServiceConfig = GetServiceConfig(lpStr);
|
||||
if (lpServiceConfig)
|
||||
/* Get a list of service dependents */
|
||||
lpDependants = TV1_GetDependants(pDlgInfo, hService);
|
||||
if (lpDependants)
|
||||
{
|
||||
/* Does this item need a +/- box? */
|
||||
bHasChildren = lpServiceConfig->lpDependencies ? TRUE : FALSE;
|
||||
lpStr = lpDependants;
|
||||
|
||||
/* Add it */
|
||||
AddItemToTreeView(pDlgInfo->hDependsTreeView1,
|
||||
hParent,
|
||||
lpServiceConfig->lpDisplayName,
|
||||
lpStr,
|
||||
lpServiceConfig->dwServiceType,
|
||||
bHasChildren);
|
||||
/* Make sure this isn't the end of the list */
|
||||
while (*lpStr)
|
||||
{
|
||||
/* Get the info for this service */
|
||||
lpServiceConfig = GetServiceConfig(lpStr);
|
||||
if (lpServiceConfig)
|
||||
{
|
||||
/* Does this item need a +/- box? */
|
||||
if (lpServiceConfig->lpDependencies &&
|
||||
*lpServiceConfig->lpDependencies != '\0')
|
||||
{
|
||||
bHasChildren = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bHasChildren = FALSE;
|
||||
}
|
||||
|
||||
/* Add it */
|
||||
AddItemToTreeView(pDlgInfo->hDependsTreeView1,
|
||||
hParent,
|
||||
lpServiceConfig->lpDisplayName,
|
||||
lpStr,
|
||||
lpServiceConfig->dwServiceType,
|
||||
bHasChildren);
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
lpServiceConfig);
|
||||
}
|
||||
|
||||
/* Move to the end of the string */
|
||||
while (*lpStr++)
|
||||
;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
lpServiceConfig);
|
||||
lpDependants);
|
||||
}
|
||||
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->hDependsTreeView1,
|
||||
NULL,
|
||||
lpNoDepends,
|
||||
NULL,
|
||||
0,
|
||||
FALSE);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
lpNoDepends);
|
||||
|
||||
/* Disable the window */
|
||||
EnableWindow(pDlgInfo->hDependsTreeView1, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Move to the end of the string */
|
||||
while (*lpStr++)
|
||||
;
|
||||
CloseServiceHandle(hService);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
lpDependants);
|
||||
}
|
||||
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->hDependsTreeView1,
|
||||
NULL,
|
||||
lpNoDepends,
|
||||
NULL,
|
||||
0,
|
||||
FALSE);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
lpNoDepends);
|
||||
|
||||
/* Disable the window */
|
||||
EnableWindow(pDlgInfo->hDependsTreeView1, FALSE);
|
||||
}
|
||||
CloseServiceHandle(hSCManager);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
TV1_Initialize(PSERVICEPROPSHEET pDlgInfo,
|
||||
SC_HANDLE hService)
|
||||
LPTSTR lpServiceName)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
|
||||
|
@ -174,7 +200,7 @@ TV1_Initialize(PSERVICEPROPSHEET pDlgInfo,
|
|||
TVSIL_NORMAL);
|
||||
|
||||
/* Set the first items in the control */
|
||||
TV1_AddDependantsToTree(pDlgInfo, NULL, hService);
|
||||
TV1_AddDependantsToTree(pDlgInfo, NULL, lpServiceName);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
|
|
@ -106,62 +106,81 @@ TV2_GetDependants(SC_HANDLE hService,
|
|||
}
|
||||
|
||||
|
||||
static VOID
|
||||
VOID
|
||||
TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
|
||||
HTREEITEM hParent,
|
||||
SC_HANDLE hService)
|
||||
LPTSTR lpServiceName)
|
||||
{
|
||||
SC_HANDLE hSCManager;
|
||||
SC_HANDLE hService;
|
||||
LPENUM_SERVICE_STATUS lpServiceStatus;
|
||||
LPTSTR lpNoDepends;
|
||||
DWORD count, i;
|
||||
BOOL bHasChildren;
|
||||
|
||||
/* Get a list of service dependents */
|
||||
lpServiceStatus = TV2_GetDependants(hService, &count);
|
||||
if (lpServiceStatus)
|
||||
/* Set the first items in each tree view */
|
||||
hSCManager = OpenSCManager(NULL,
|
||||
NULL,
|
||||
SC_MANAGER_ALL_ACCESS);
|
||||
if (hSCManager)
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
hService = OpenService(hSCManager,
|
||||
lpServiceName,
|
||||
SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
|
||||
if (hService)
|
||||
{
|
||||
/* Does this item need a +/- box? */
|
||||
bHasChildren = HasDependantServices(lpServiceStatus[i].lpServiceName);
|
||||
/* Get a list of service dependents */
|
||||
lpServiceStatus = TV2_GetDependants(hService, &count);
|
||||
if (lpServiceStatus)
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
/* Does this item need a +/- box? */
|
||||
bHasChildren = HasDependantServices(lpServiceStatus[i].lpServiceName);
|
||||
|
||||
/* Add it */
|
||||
AddItemToTreeView(pDlgInfo->hDependsTreeView2,
|
||||
hParent,
|
||||
lpServiceStatus[i].lpDisplayName,
|
||||
lpServiceStatus[i].lpServiceName,
|
||||
lpServiceStatus[i].ServiceStatus.dwServiceType,
|
||||
bHasChildren);
|
||||
/* Add it */
|
||||
AddItemToTreeView(pDlgInfo->hDependsTreeView2,
|
||||
hParent,
|
||||
lpServiceStatus[i].lpDisplayName,
|
||||
lpServiceStatus[i].lpServiceName,
|
||||
lpServiceStatus[i].ServiceStatus.dwServiceType,
|
||||
bHasChildren);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
CloseServiceHandle(hService);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
CloseServiceHandle(hSCManager);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
TV2_Initialize(PSERVICEPROPSHEET pDlgInfo,
|
||||
SC_HANDLE hService)
|
||||
LPTSTR lpServiceName)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
|
||||
|
@ -178,7 +197,7 @@ TV2_Initialize(PSERVICEPROPSHEET pDlgInfo,
|
|||
TVSIL_NORMAL);
|
||||
|
||||
/* Set the first items in the control */
|
||||
TV2_AddDependantsToTree(pDlgInfo, NULL, hService);
|
||||
TV2_AddDependantsToTree(pDlgInfo, NULL, lpServiceName);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
|
|
@ -121,15 +121,15 @@ typedef struct _SERVICEPROPSHEET
|
|||
HTREEITEM AddItemToTreeView(HWND hTreeView, HTREEITEM hRoot, LPTSTR lpDisplayName, LPTSTR lpServiceName, ULONG serviceType, BOOL bHasChildren);
|
||||
|
||||
/* dependencies */
|
||||
//LPENUM_SERVICE_STATUS GetServiceDependents(SC_HANDLE hService, LPDWORD lpdwCount);
|
||||
INT_PTR CALLBACK StopDependsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
//LPTSTR GetDependentServices(SC_HANDLE hService);
|
||||
|
||||
/* tv1_dependencies */
|
||||
BOOL TV1_Initialize(PSERVICEPROPSHEET pDlgInfo, SC_HANDLE hService);
|
||||
BOOL TV1_Initialize(PSERVICEPROPSHEET pDlgInfo, LPTSTR lpServiceName);
|
||||
VOID TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPTSTR lpServiceName);
|
||||
|
||||
/* tv2_dependencies */
|
||||
BOOL TV2_Initialize(PSERVICEPROPSHEET pDlgInfo, SC_HANDLE hService);
|
||||
BOOL TV2_Initialize(PSERVICEPROPSHEET pDlgInfo, LPTSTR lpServiceName);
|
||||
VOID TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPTSTR lpServiceName);
|
||||
|
||||
LONG APIENTRY OpenPropSheet(PMAIN_WND_INFO Info);
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
HTREEITEM
|
||||
AddItemToTreeView(HWND hTreeView,
|
||||
HTREEITEM hRoot,
|
||||
HTREEITEM hParent,
|
||||
LPTSTR lpDisplayName,
|
||||
LPTSTR lpServiceName,
|
||||
ULONG serviceType,
|
||||
ULONG ServiceType,
|
||||
BOOL bHasChildren)
|
||||
{
|
||||
TV_ITEM tvi;
|
||||
|
@ -24,35 +24,52 @@ AddItemToTreeView(HWND hTreeView,
|
|||
ZeroMemory(&tvi, sizeof(tvi));
|
||||
ZeroMemory(&tvins, sizeof(tvins));
|
||||
|
||||
tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_CHILDREN;
|
||||
tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_CHILDREN;
|
||||
tvi.pszText = lpDisplayName;
|
||||
tvi.cchTextMax = _tcslen(lpDisplayName);
|
||||
tvi.cChildren = bHasChildren; //I_CHILDRENCALLBACK;
|
||||
|
||||
if (serviceType == SERVICE_WIN32_OWN_PROCESS ||
|
||||
serviceType == SERVICE_WIN32_SHARE_PROCESS)
|
||||
switch (ServiceType)
|
||||
{
|
||||
tvi.iImage = 1;
|
||||
tvi.iSelectedImage = 1;
|
||||
case SERVICE_WIN32_OWN_PROCESS:
|
||||
case SERVICE_WIN32_SHARE_PROCESS:
|
||||
tvi.iImage = 1;
|
||||
tvi.iSelectedImage = 1;
|
||||
break;
|
||||
|
||||
case SERVICE_KERNEL_DRIVER:
|
||||
case SERVICE_FILE_SYSTEM_DRIVER:
|
||||
tvi.iImage = 2;
|
||||
tvi.iSelectedImage = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
tvi.iImage = 0;
|
||||
tvi.iSelectedImage = 0;
|
||||
break;
|
||||
}
|
||||
else if (serviceType == SERVICE_KERNEL_DRIVER ||
|
||||
serviceType == SERVICE_FILE_SYSTEM_DRIVER)
|
||||
|
||||
/* Attach the service name */
|
||||
tvi.lParam = (LPARAM)(LPTSTR)HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
(_tcslen(lpServiceName) + 1) * sizeof(TCHAR));
|
||||
if (tvi.lParam)
|
||||
{
|
||||
tvi.iImage = 2;
|
||||
tvi.iSelectedImage = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
tvi.iImage = 0;
|
||||
tvi.iSelectedImage = 0;
|
||||
_tcscpy((LPTSTR)tvi.lParam, lpServiceName);
|
||||
}
|
||||
|
||||
tvins.item = tvi;
|
||||
tvins.hParent = hRoot;
|
||||
tvins.hParent = hParent;
|
||||
|
||||
return TreeView_InsertItem(hTreeView, &tvins);
|
||||
}
|
||||
|
||||
static VOID
|
||||
DestroyTreeView(HWND hTreeView)
|
||||
{
|
||||
//FIXME: traverse the nodes and free the strings
|
||||
}
|
||||
|
||||
/*
|
||||
static BOOL
|
||||
TreeView_GetItemText(HWND hTreeView,
|
||||
|
@ -69,15 +86,30 @@ TreeView_GetItemText(HWND hTreeView,
|
|||
|
||||
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;
|
||||
}
|
||||
*/
|
||||
|
||||
static BOOL
|
||||
static VOID
|
||||
InitDependPage(PSERVICEPROPSHEET pDlgInfo)
|
||||
{
|
||||
SC_HANDLE hSCManager;
|
||||
SC_HANDLE hService;
|
||||
BOOL bRet = FALSE;
|
||||
|
||||
/* Initialize the image list */
|
||||
pDlgInfo->hDependsImageList = InitImageList(IDI_NODEPENDS,
|
||||
IDI_DRIVER,
|
||||
|
@ -85,32 +117,11 @@ InitDependPage(PSERVICEPROPSHEET pDlgInfo)
|
|||
GetSystemMetrics(SM_CXSMICON),
|
||||
IMAGE_ICON);
|
||||
|
||||
/* Set the first items in each tree view */
|
||||
hSCManager = OpenSCManager(NULL,
|
||||
NULL,
|
||||
SC_MANAGER_ALL_ACCESS);
|
||||
if (hSCManager)
|
||||
{
|
||||
hService = OpenService(hSCManager,
|
||||
pDlgInfo->pService->lpServiceName,
|
||||
SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
|
||||
if (hService)
|
||||
{
|
||||
/* Set the first tree view */
|
||||
TV1_Initialize(pDlgInfo, hService);
|
||||
/* Set the first tree view */
|
||||
TV1_Initialize(pDlgInfo, pDlgInfo->pService->lpServiceName);
|
||||
|
||||
/* Set the second tree view */
|
||||
TV2_Initialize(pDlgInfo, hService);
|
||||
|
||||
bRet = TRUE;
|
||||
|
||||
CloseServiceHandle(hService);
|
||||
}
|
||||
|
||||
CloseServiceHandle(hSCManager);
|
||||
}
|
||||
|
||||
return bRet;
|
||||
/* Set the second tree view */
|
||||
TV2_Initialize(pDlgInfo, pDlgInfo->pService->lpServiceName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,7 +173,14 @@ DependenciesPageProc(HWND hwndDlg,
|
|||
|
||||
if (lpnmtv->action == TVE_EXPAND)
|
||||
{
|
||||
|
||||
if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE1)
|
||||
{
|
||||
TV1_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPTSTR)lpnmtv->itemNew.lParam);
|
||||
}
|
||||
else if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE2)
|
||||
{
|
||||
TV2_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPTSTR)lpnmtv->itemNew.lParam);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -178,6 +196,9 @@ DependenciesPageProc(HWND hwndDlg,
|
|||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
DestroyTreeView(pDlgInfo->hDependsTreeView1);
|
||||
DestroyTreeView(pDlgInfo->hDependsTreeView2);
|
||||
|
||||
if (pDlgInfo->hDependsImageList)
|
||||
ImageList_Destroy(pDlgInfo->hDependsImageList);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue