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 12 BOOL Delete(LPCTSTR ServiceName) 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, 24 SC_MANAGER_CONNECT); 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) 51 ReportLastError(); 52 53 if (hSc) 54 CloseServiceHandle(hSc); 55 56 if (hSCManager) 57 CloseServiceHandle(hSCManager); 58 59 return bRet; 60 } 61