ReactOS  0.4.12-dev-36-g472787f
delete.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Services
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: base/applications/sc/delete.c
5  * PURPOSE: Delete a service
6  * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
7  *
8  */
9 
10 #include "sc.h"
11 
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
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#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
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
#define DELETE
Definition: nt_native.h:57