mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 15:23:04 +00:00
Create a branch for network fixes.
svn path=/branches/aicom-network-fixes/; revision=34994
This commit is contained in:
parent
0e213bbc00
commit
c501d8112c
18148 changed files with 0 additions and 860488 deletions
89
base/applications/sc/create.c
Normal file
89
base/applications/sc/create.c
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Services
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/system/sc/create.c
|
||||
* PURPOSE: Create a service
|
||||
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sc.h"
|
||||
|
||||
BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs)
|
||||
{
|
||||
SC_HANDLE hSCManager;
|
||||
SC_HANDLE hSc;
|
||||
BOOL bRet = FALSE;
|
||||
|
||||
DWORD dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
DWORD dwStartType = SERVICE_DEMAND_START;
|
||||
DWORD dwErrorControl = SERVICE_ERROR_NORMAL;
|
||||
LPCTSTR lpBinaryPathName = NULL;
|
||||
LPCTSTR lpLoadOrderGroup = NULL;
|
||||
LPDWORD lpdwTagId = NULL;
|
||||
LPCTSTR lpDependencies = NULL;
|
||||
LPCTSTR lpServiceStartName = NULL;
|
||||
LPCTSTR lpPassword = NULL;
|
||||
|
||||
/* quick hack to get it working */
|
||||
lpBinaryPathName = *ServiceArgs;
|
||||
|
||||
#ifdef SCDBG
|
||||
_tprintf(_T("service name - %s\n"), ServiceName);
|
||||
_tprintf(_T("display name - %s\n"), ServiceName);
|
||||
_tprintf(_T("service type - %lu\n"), dwServiceType);
|
||||
_tprintf(_T("start type - %lu\n"), dwStartType);
|
||||
_tprintf(_T("error control - %lu\n"), dwErrorControl);
|
||||
_tprintf(_T("Binary path - %s\n"), lpBinaryPathName);
|
||||
_tprintf(_T("load order group - %s\n"), lpLoadOrderGroup);
|
||||
_tprintf(_T("tag - %lu\n"), *lpdwTagId);
|
||||
_tprintf(_T("dependincies - %s\n"), lpDependencies);
|
||||
_tprintf(_T("account start name - %s\n"), lpServiceStartName);
|
||||
_tprintf(_T("account password - %s\n"), lpPassword);
|
||||
#endif
|
||||
|
||||
if (!ServiceName)
|
||||
{
|
||||
CreateUsage();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hSCManager = OpenSCManager(NULL,
|
||||
NULL,
|
||||
SC_MANAGER_CREATE_SERVICE);
|
||||
if (hSCManager == NULL)
|
||||
{
|
||||
ReportLastError();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hSc = CreateService(hSCManager,
|
||||
ServiceName,
|
||||
ServiceName,
|
||||
SERVICE_ALL_ACCESS,
|
||||
dwServiceType,
|
||||
dwStartType,
|
||||
dwErrorControl,
|
||||
lpBinaryPathName,
|
||||
lpLoadOrderGroup,
|
||||
lpdwTagId,
|
||||
lpDependencies,
|
||||
lpServiceStartName,
|
||||
lpPassword);
|
||||
|
||||
if (hSc == NULL)
|
||||
{
|
||||
ReportLastError();
|
||||
CloseServiceHandle(hSCManager);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tprintf(_T("[SC] CreateService SUCCESS\n"));
|
||||
|
||||
CloseServiceHandle(hSc);
|
||||
CloseServiceHandle(hSCManager);
|
||||
bRet = TRUE;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue