3fe1e573cdfdfa1296ce1604a1fe02c450be04d2
[reactos.git] / reactos / subsys / system / sc / create.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS SC utility
4 * FILE: subsys/system/sc/create.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 BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs)
15 {
16 SC_HANDLE hSc;
17 LPCTSTR BinaryPathName = *++ServiceArgs;
18 LPCTSTR *Options = ++ServiceArgs;
19
20 if ((! ServiceName) || (! BinaryPathName))
21 return CreateUsage();
22
23 /* testing */
24 printf("service to create - %s\n", ServiceName);
25 printf("Binary path - %s\n", BinaryPathName);
26 printf("Arguments :\n");
27 while (*Options)
28 {
29 printf("%s\n", *Options);
30 Options++;
31 }
32
33 hSc = CreateService(hSCManager,
34 ServiceName,
35 ServiceName,
36 SERVICE_ALL_ACCESS,
37 SERVICE_WIN32_OWN_PROCESS,
38 SERVICE_DEMAND_START,
39 SERVICE_ERROR_NORMAL,
40 BinaryPathName,
41 NULL,
42 NULL,
43 NULL,
44 NULL,
45 NULL);
46
47 if (hSc == NULL)
48 {
49 _tprintf(_T("CreateService failed\n"));
50 ReportLastError();
51 return FALSE;
52 }
53 else
54 {
55 CloseServiceHandle(hSc);
56 return TRUE;
57 }
58 }