/*
* PROJECT: ReactOS Services
* LICENSE: GPL - See COPYING in the top level directory
- * FILE: base/system/sc/start.c
+ * FILE: base/applications/sc/start.c
* PURPOSE: Start a service
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
*
SC_HANDLE hSCManager = NULL;
SC_HANDLE hSc = NULL;
LPSERVICE_STATUS_PROCESS pServiceInfo = NULL;
+ BOOL bResult = TRUE;
#ifdef SCDBG
LPCTSTR *TmpArgs = ServiceArgs;
SC_MANAGER_CONNECT);
if (hSCManager == NULL)
{
- ReportLastError();
- return FALSE;
+ _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError());
+ bResult = FALSE;
+ goto done;
}
hSc = OpenService(hSCManager,
ServiceName,
SERVICE_START | SERVICE_QUERY_STATUS);
-
if (hSc == NULL)
- goto fail;
+ {
+ _tprintf(_T("[SC] OpenService FAILED %lu:\n\n"), GetLastError());
+ bResult = FALSE;
+ goto done;
+ }
if (!ArgCount)
{
ServiceArgs = NULL;
}
- if (! StartService(hSc,
- ArgCount,
- ServiceArgs))
+ if (!StartService(hSc,
+ ArgCount,
+ ServiceArgs))
{
_tprintf(_T("[SC] StartService FAILED %lu:\n\n"), GetLastError());
- goto fail;
+ bResult = FALSE;
+ goto done;
}
pServiceInfo = QueryService(ServiceName);
PrintService(ServiceName,
pServiceInfo,
TRUE);
+
+ HeapFree(GetProcessHeap(), 0, pServiceInfo);
}
- HeapFree(GetProcessHeap(), 0, pServiceInfo);
- CloseServiceHandle(hSc);
- CloseServiceHandle(hSCManager);
+done:
+ if (bResult == FALSE)
+ ReportLastError();
- return TRUE;
+ if (hSc)
+ CloseServiceHandle(hSc);
-fail:
- ReportLastError();
- if (pServiceInfo) HeapFree(GetProcessHeap(), 0, pServiceInfo);
- if (hSc) CloseServiceHandle(hSc);
- if (hSCManager) CloseServiceHandle(hSCManager);
- return FALSE;
+ if (hSCManager)
+ CloseServiceHandle(hSCManager);
+ return bResult;
}