Add information letting us know creation deletion of services has worked.
[reactos.git] / reactos / subsys / system / sc / control.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS SC utility
4 * FILE: subsys/system/sc/control.c
5 * PURPOSE: control ReactOS services
6 * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
7 * REVISIONS:
8 * Ged Murphy 20/10/05 Created
9 *
10 */
11
12 #include "sc.h"
13
14 /*
15 * handles the following commands:
16 * control, continue, interrogate, pause, stop
17 */
18
19 BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args)
20 {
21 SC_HANDLE hSc;
22 SERVICE_STATUS Status;
23
24 #ifdef SCDBG
25 /* testing */
26 _tprintf(_T("service to control - %s\n\n"), ServiceName);
27 _tprintf(_T("command - %lu\n\n"), Control);
28 _tprintf(_T("Arguments :\n"));
29 while (*Args)
30 {
31 printf("%s\n", *Args);
32 Args++;
33 }
34 #endif /* SCDBG */
35
36 hSc = OpenService(hSCManager, ServiceName,
37 SERVICE_INTERROGATE | SERVICE_PAUSE_CONTINUE |
38 SERVICE_STOP | SERVICE_USER_DEFINED_CONTROL |
39 SERVICE_QUERY_STATUS);
40
41 if (hSc == NULL)
42 {
43 _tprintf(_T("openService failed\n"));
44 ReportLastError();
45 return FALSE;
46 }
47
48 if (! ControlService(hSc, Control, &Status))
49 {
50 _tprintf(_T("[SC] controlService FAILED %lu:\n\n"), GetLastError());
51 ReportLastError();
52 return FALSE;
53 }
54
55 CloseServiceHandle(hSc);
56
57 /* print the status information */
58
59 return TRUE;
60
61 }