ReactOS  0.4.11-dev-946-g431643b
delete.c File Reference
#include "sc.h"
Include dependency graph for delete.c:

Go to the source code of this file.

Functions

BOOL Delete (LPCTSTR ServiceName)
 

Function Documentation

◆ Delete()

BOOL Delete ( LPCTSTR  ServiceName)

Definition at line 12 of file delete.c.

Referenced by cmdUse(), DECLARE_INTERFACE_(), PropertySetStorage_Delete(), RawCheckForDismount(), ScControl(), test_SHPropStg_functions(), UDFCleanUpFcbChain(), UpdateRegistry(), and VfatCheckForDismount().

13 {
14  SC_HANDLE hSCManager = NULL;
15  SC_HANDLE hSc = NULL;
16  BOOL bRet = TRUE;
17 
18 #ifdef SCDBG
19  _tprintf(_T("service to delete - %s\n\n"), ServiceName);
20 #endif
21 
22  hSCManager = OpenSCManager(NULL,
23  NULL,
25  if (hSCManager == NULL)
26  {
27  _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError());
28  bRet = FALSE;
29  goto done;
30  }
31 
32  hSc = OpenService(hSCManager, ServiceName, DELETE);
33  if (hSc == NULL)
34  {
35  _tprintf(_T("[SC] OpenService FAILED %lu:\n\n"), GetLastError());
36  bRet = FALSE;
37  goto done;
38  }
39 
40  if (!DeleteService(hSc))
41  {
42  _tprintf(_T("[SC] DeleteService FAILED %lu:\n\n"), GetLastError());
43  bRet = FALSE;
44  goto done;
45  }
46 
47  _tprintf(_T("[SC] DeleteService SUCCESS\n\n"));
48 
49 done:
50  if (bRet == FALSE)
52 
53  if (hSc)
54  CloseServiceHandle(hSc);
55 
56  if (hSCManager)
57  CloseServiceHandle(hSCManager);
58 
59  return bRet;
60 }
#define _tprintf
Definition: tchar.h:506
#define TRUE
Definition: types.h:120
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteService(SC_HANDLE hService)
Definition: scm.c:915
#define OpenService
Definition: winsvc.h:576
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
#define OpenSCManager
Definition: winsvc.h:575
#define _T(x)
Definition: vfdio.h:22
unsigned int BOOL
Definition: ntddk_ex.h:94
LPTSTR ServiceName
Definition: ServiceMain.c:15
SC_HANDLE hSCManager
Definition: sc.c:12
VOID ReportLastError(VOID)
Definition: sc.c:15
#define DELETE
Definition: nt_native.h:57