ReactOS  0.4.12-dev-36-g472787f
dependencies_tv1.c File Reference
#include "precomp.h"
Include dependency graph for dependencies_tv1.c:

Go to the source code of this file.

Functions

LPWSTR TV1_GetDependants (SC_HANDLE hService)
 
VOID TV1_AddDependantsToTree (PDEPENDDATA pDependData, HTREEITEM hParent, LPWSTR lpServiceName)
 
BOOL TV1_Initialize (PDEPENDDATA pDependData, LPWSTR lpServiceName)
 

Function Documentation

◆ TV1_AddDependantsToTree()

VOID TV1_AddDependantsToTree ( PDEPENDDATA  pDependData,
HTREEITEM  hParent,
LPWSTR  lpServiceName 
)

Definition at line 82 of file dependencies_tv1.c.

Referenced by DependenciesPageProc(), and TV1_Initialize().

85 {
86  SC_HANDLE hSCManager;
87  SC_HANDLE hService;
88  LPQUERY_SERVICE_CONFIG lpServiceConfig;
89  LPWSTR lpDependants;
90  LPWSTR lpStr;
91  LPWSTR lpNoDepends;
92  BOOL bHasChildren;
93 
94  hSCManager = OpenSCManagerW(NULL,
95  NULL,
97  if (hSCManager)
98  {
99  hService = OpenServiceW(hSCManager,
100  lpServiceName,
102  if (hService)
103  {
104  /* Get a list of service dependents */
105  lpDependants = TV1_GetDependants(hService);
106  if (lpDependants)
107  {
108  lpStr = lpDependants;
109 
110  /* Make sure this isn't the end of the list */
111  while (*lpStr)
112  {
113  /* Get the info for this service */
114  lpServiceConfig = GetServiceConfig(lpStr);
115  if (lpServiceConfig)
116  {
117  /* Does this item need a +/- box? */
118  if (lpServiceConfig->lpDependencies &&
119  *lpServiceConfig->lpDependencies != '\0')
120  {
121  bHasChildren = TRUE;
122  }
123  else
124  {
125  bHasChildren = FALSE;
126  }
127 
128  /* Add it */
130  hParent,
131  lpServiceConfig->lpDisplayName,
132  lpStr,
133  lpServiceConfig->dwServiceType,
134  bHasChildren);
135 
137  0,
138  lpServiceConfig);
139  }
140 
141  /* Move to the end of the string */
142  while (*lpStr++)
143  ;
144  }
145 
147  0,
148  lpDependants);
149  }
150  else
151  {
152  /* If there is no parent, set the tree to 'no dependencies' */
153  if (!hParent)
154  {
155  /* Load the 'No dependencies' string */
157 
159  NULL,
160  lpNoDepends,
161  NULL,
162  0,
163  FALSE);
164 
165  LocalFree(lpNoDepends);
166 
167  /* Disable the window */
168  EnableWindow(pDependData->hDependsTreeView1, FALSE);
169  }
170  }
171 
172  CloseServiceHandle(hService);
173  }
174 
175  CloseServiceHandle(hSCManager);
176  }
177 }
#define TRUE
Definition: types.h:120
static INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:60
#define SERVICE_ENUMERATE_DEPENDENTS
Definition: winsvc.h:56
HINSTANCE hInstance
Definition: charmap.c:20
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2102
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
#define SERVICE_QUERY_STATUS
Definition: winsvc.h:55
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
#define IDS_NO_DEPENDS
Definition: resource.h:180
HWND hDependsTreeView1
Definition: precomp.h:139
LPQUERY_SERVICE_CONFIG GetServiceConfig(LPWSTR lpServiceName)
Definition: query.c:29
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2010
LPWSTR TV1_GetDependants(SC_HANDLE hService)
SC_HANDLE hSCManager
Definition: sc.c:12
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define SC_MANAGER_ALL_ACCESS
Definition: winsvc.h:13
#define SERVICE_QUERY_CONFIG
Definition: winsvc.h:53
HTREEITEM AddItemToTreeView(HWND hTreeView, HTREEITEM hRoot, LPWSTR lpDisplayName, LPWSTR lpServiceName, ULONG serviceType, BOOL bHasChildren)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ TV1_GetDependants()

LPWSTR TV1_GetDependants ( SC_HANDLE  hService)

Definition at line 13 of file dependencies_tv1.c.

Referenced by TV1_AddDependantsToTree().

14 {
15  LPQUERY_SERVICE_CONFIG lpServiceConfig;
16  LPWSTR lpStr = NULL;
17  DWORD bytesNeeded;
18  DWORD bytes;
19 
20  /* Get the info for this service */
21  if (!QueryServiceConfigW(hService,
22  NULL,
23  0,
24  &bytesNeeded) &&
26  {
27  lpServiceConfig = HeapAlloc(ProcessHeap,
28  0,
29  bytesNeeded);
30  if (lpServiceConfig)
31  {
32  if (QueryServiceConfigW(hService,
33  lpServiceConfig,
34  bytesNeeded,
35  &bytesNeeded))
36  {
37  /* Does this service have any dependencies? */
38  if (lpServiceConfig->lpDependencies &&
39  *lpServiceConfig->lpDependencies != '\0')
40  {
41  lpStr = lpServiceConfig->lpDependencies;
42  bytes = 0;
43 
44  /* Work out how many bytes we need to hold the list */
45  for (;;)
46  {
47  bytes++;
48 
49  if (!*lpStr && !*(lpStr + 1))
50  {
51  bytes++;
52  break;
53  }
54 
55  lpStr++;
56  }
57 
58  /* Allocate and copy the list */
59  bytes *= sizeof(WCHAR);
60  lpStr = HeapAlloc(ProcessHeap,
61  0,
62  bytes);
63  if (lpStr)
64  {
65  CopyMemory(lpStr,
66  lpServiceConfig->lpDependencies,
67  bytes);
68  }
69  }
70  }
71 
73  0,
74  lpServiceConfig);
75  }
76  }
77 
78  return lpStr;
79 }
BOOL WINAPI QueryServiceConfigW(SC_HANDLE hService, LPQUERY_SERVICE_CONFIGW lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2233
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define WCHAR
Definition: msvc.h:43
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CopyMemory
Definition: winbase.h:1633
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE ProcessHeap
Definition: servman.c:15
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ TV1_Initialize()

BOOL TV1_Initialize ( PDEPENDDATA  pDependData,
LPWSTR  lpServiceName 
)

Definition at line 180 of file dependencies_tv1.c.

Referenced by InitDependPage().

182 {
183  BOOL bRet = FALSE;
184 
185  /* Associate the imagelist with TV1 */
186  pDependData->hDependsTreeView1 = GetDlgItem(pDependData->hDependsWnd, IDC_DEPEND_TREE1);
187  if (!pDependData->hDependsTreeView1)
188  {
189  ImageList_Destroy(pDependData->hDependsImageList);
190  pDependData->hDependsImageList = NULL;
191  return FALSE;
192  }
194  pDependData->hDependsImageList,
195  TVSIL_NORMAL);
196 
197  /* Set the first items in the control */
198  TV1_AddDependantsToTree(pDependData, NULL, lpServiceName);
199 
200  return bRet;
201 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define IDC_DEPEND_TREE1
Definition: resource.h:177
HIMAGELIST hDependsImageList
Definition: precomp.h:137
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:893
smooth NULL
Definition: ftsmooth.c:416
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3414
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND hDependsTreeView1
Definition: precomp.h:139
VOID TV1_AddDependantsToTree(PDEPENDDATA pDependData, HTREEITEM hParent, LPWSTR lpServiceName)
HWND hDependsWnd
Definition: precomp.h:138
#define TVSIL_NORMAL
Definition: commctrl.h:3410