/*
* PROJECT: ReactOS Services
* LICENSE: GPL - See COPYING in the top level directory
- * FILE: base/applications/mscutils/servman/tv1_dependencies.c
+ * FILE: base/applications/mscutils/servman/dependencies_tv1.c
* PURPOSE: Helper functions for service dependents
* COPYRIGHT: Copyright 2009 Ged Murphy <gedmurphy@reactos.org>
*
#include "precomp.h"
-LPTSTR
-TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
- SC_HANDLE hService)
+LPWSTR
+TV1_GetDependants(SC_HANDLE hService)
{
LPQUERY_SERVICE_CONFIG lpServiceConfig;
- LPTSTR lpStr = NULL;
+ LPWSTR lpStr = NULL;
DWORD bytesNeeded;
DWORD bytes;
/* Get the info for this service */
- if (!QueryServiceConfig(hService,
- NULL,
- 0,
- &bytesNeeded) &&
+ if (!QueryServiceConfigW(hService,
+ NULL,
+ 0,
+ &bytesNeeded) &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
lpServiceConfig = HeapAlloc(ProcessHeap,
bytesNeeded);
if (lpServiceConfig)
{
- if (QueryServiceConfig(hService,
- lpServiceConfig,
- bytesNeeded,
- &bytesNeeded))
+ if (QueryServiceConfigW(hService,
+ lpServiceConfig,
+ bytesNeeded,
+ &bytesNeeded))
{
/* Does this service have any dependencies? */
if (lpServiceConfig->lpDependencies &&
bytes = 0;
/* Work out how many bytes we need to hold the list */
- while (TRUE)
+ for (;;)
{
bytes++;
}
/* Allocate and copy the list */
- bytes *= sizeof(TCHAR);
+ bytes *= sizeof(WCHAR);
lpStr = HeapAlloc(ProcessHeap,
0,
bytes);
}
VOID
-TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
+TV1_AddDependantsToTree(PDEPENDDATA pDependData,
HTREEITEM hParent,
- LPTSTR lpServiceName)
+ LPWSTR lpServiceName)
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
LPQUERY_SERVICE_CONFIG lpServiceConfig;
- LPTSTR lpDependants;
- LPTSTR lpStr;
- LPTSTR lpNoDepends;
+ LPWSTR lpDependants;
+ LPWSTR lpStr;
+ LPWSTR lpNoDepends;
BOOL bHasChildren;
- hSCManager = OpenSCManager(NULL,
- NULL,
- SC_MANAGER_ALL_ACCESS);
+ hSCManager = OpenSCManagerW(NULL,
+ NULL,
+ SC_MANAGER_ALL_ACCESS);
if (hSCManager)
{
- hService = OpenService(hSCManager,
- lpServiceName,
- SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
+ hService = OpenServiceW(hSCManager,
+ lpServiceName,
+ SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
if (hService)
{
/* Get a list of service dependents */
- lpDependants = TV1_GetDependants(pDlgInfo, hService);
+ lpDependants = TV1_GetDependants(hService);
if (lpDependants)
{
lpStr = lpDependants;
}
/* Add it */
- AddItemToTreeView(pDlgInfo->hDependsTreeView1,
+ AddItemToTreeView(pDependData->hDependsTreeView1,
hParent,
lpServiceConfig->lpDisplayName,
lpStr,
/* Load the 'No dependencies' string */
AllocAndLoadString(&lpNoDepends, hInstance, IDS_NO_DEPENDS);
- AddItemToTreeView(pDlgInfo->hDependsTreeView1,
+ AddItemToTreeView(pDependData->hDependsTreeView1,
NULL,
lpNoDepends,
NULL,
LocalFree(lpNoDepends);
/* Disable the window */
- EnableWindow(pDlgInfo->hDependsTreeView1, FALSE);
+ EnableWindow(pDependData->hDependsTreeView1, FALSE);
}
}
}
BOOL
-TV1_Initialize(PSERVICEPROPSHEET pDlgInfo,
- LPTSTR lpServiceName)
+TV1_Initialize(PDEPENDDATA pDependData,
+ LPWSTR lpServiceName)
{
BOOL bRet = FALSE;
- /* Accociate the imagelist with TV1 */
- pDlgInfo->hDependsTreeView1 = GetDlgItem(pDlgInfo->hDependsWnd, IDC_DEPEND_TREE1);
- if (!pDlgInfo->hDependsTreeView1)
+ /* Associate the imagelist with TV1 */
+ pDependData->hDependsTreeView1 = GetDlgItem(pDependData->hDependsWnd, IDC_DEPEND_TREE1);
+ if (!pDependData->hDependsTreeView1)
{
- ImageList_Destroy(pDlgInfo->hDependsImageList);
- pDlgInfo->hDependsImageList = NULL;
+ ImageList_Destroy(pDependData->hDependsImageList);
+ pDependData->hDependsImageList = NULL;
return FALSE;
}
- (void)TreeView_SetImageList(pDlgInfo->hDependsTreeView1,
- pDlgInfo->hDependsImageList,
+ (void)TreeView_SetImageList(pDependData->hDependsTreeView1,
+ pDependData->hDependsImageList,
TVSIL_NORMAL);
/* Set the first items in the control */
- TV1_AddDependantsToTree(pDlgInfo, NULL, lpServiceName);
+ TV1_AddDependantsToTree(pDependData, NULL, lpServiceName);
return bRet;
}