ReactOS  0.4.14-dev-50-g13bb5e2
depend.c File Reference
#include "sc.h"
Include dependency graph for depend.c:

Go to the source code of this file.

Functions

BOOL EnumDepend (LPCTSTR ServiceName)
 

Function Documentation

◆ EnumDepend()

BOOL EnumDepend ( LPCTSTR  ServiceName)

Definition at line 12 of file depend.c.

13 {
14  SC_HANDLE hManager = NULL;
15  SC_HANDLE hService = NULL;
16  BOOL bResult = TRUE;
17  DWORD BufferSize = 0;
18  DWORD EntriesRead = 0;
20  DWORD i;
21 
22  hManager = OpenSCManager(NULL,
23  NULL,
25  if (hManager == NULL)
26  {
27  _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError());
28  bResult = FALSE;
29  goto done;
30  }
31 
33  if (hService == NULL)
34  {
35  _tprintf(_T("[SC] OpenService FAILED %lu:\n\n"), GetLastError());
36  bResult = FALSE;
37  goto done;
38  }
39 
40  if (!EnumDependentServices(hService,
42  NULL,
43  0,
44  &BufferSize,
45  &EntriesRead))
46  {
47  if (BufferSize == 0)
48  {
49  _tprintf(_T("[SC] EnumDependentServices FAILED %lu:\n\n"), GetLastError());
50  bResult = FALSE;
51  goto done;
52  }
53  }
54 
56  if (pBuffer == NULL)
57  {
59  _tprintf(_T("[SC] HeapAlloc FAILED %lu:\n\n"), GetLastError());
60  bResult = FALSE;
61  goto done;
62  }
63 
64  if (!EnumDependentServices(hService,
66  pBuffer,
67  BufferSize,
68  &BufferSize,
69  &EntriesRead))
70  {
71  _tprintf(_T("[SC] EnumDependentServices FAILED %lu:\n\n"), GetLastError());
72  bResult = FALSE;
73  goto done;
74  }
75 
76  _tprintf(_T("Enum: entriesRead = %lu\n"), EntriesRead);
77 
78  for (i = 0; i < EntriesRead; i++)
79  {
80  _tprintf(_T("\n"));
81  _tprintf(_T("SERVICE_NAME: %s\n"), pBuffer[i].lpServiceName);
82  _tprintf(_T("DISPLAY_NAME: %s\n"), pBuffer[i].lpDisplayName);
84  }
85 
86 done:
87  if (bResult == FALSE)
89 
90  if (pBuffer != NULL)
92 
93  if (hService)
94  CloseServiceHandle(hService);
95 
96  if (hManager)
97  CloseServiceHandle(hManager);
98 
99  return bResult;
100 }
#define _tprintf
Definition: tchar.h:506
#define TRUE
Definition: types.h:120
#define EnumDependentServices
Definition: winsvc.h:570
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SERVICE_STATE_ALL
Definition: winsvc.h:52
#define SERVICE_ENUMERATE_DEPENDENTS
Definition: winsvc.h:56
#define OpenService
Definition: winsvc.h:576
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
VOID PrintServiceStatus(LPSERVICE_STATUS pStatus)
Definition: print.c:39
#define OpenSCManager
Definition: winsvc.h:575
#define _T(x)
Definition: vfdio.h:22
LPTSTR ServiceName
Definition: ServiceMain.c:15
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define BufferSize
Definition: classpnp.h:419
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
VOID ReportLastError(VOID)
Definition: sc.c:15
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by ScControl().