2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/sc/start.c
5 * PURPOSE: Start a service
6 * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
12 BOOL
Start(LPCTSTR ServiceName
, LPCTSTR
*ServiceArgs
, INT ArgCount
)
14 SC_HANDLE hSCManager
= NULL
;
16 LPSERVICE_STATUS_PROCESS pServiceInfo
= NULL
;
19 LPCTSTR
*TmpArgs
= ServiceArgs
;
20 INT TmpCnt
= ArgCount
;
21 _tprintf(_T("service to control - %s\n"), ServiceName
);
22 _tprintf(_T("Arguments:\n"));
25 _tprintf(_T(" %s\n"), *TmpArgs
);
32 hSCManager
= OpenSCManager(NULL
,
35 if (hSCManager
== NULL
)
41 hSc
= OpenService(hSCManager
,
43 SERVICE_START
| SERVICE_QUERY_STATUS
);
53 if (! StartService(hSc
,
57 _tprintf(_T("[SC] StartService FAILED %lu:\n\n"), GetLastError());
61 pServiceInfo
= QueryService(ServiceName
);
62 if (pServiceInfo
!= NULL
)
64 PrintService(ServiceName
,
69 HeapFree(GetProcessHeap(), 0, pServiceInfo
);
70 CloseServiceHandle(hSc
);
71 CloseServiceHandle(hSCManager
);
77 if (pServiceInfo
) HeapFree(GetProcessHeap(), 0, pServiceInfo
);
78 if (hSc
) CloseServiceHandle(hSc
);
79 if (hSCManager
) CloseServiceHandle(hSCManager
);