static BOOL
DoStartService(PMAIN_WND_INFO Info,
- HWND hProgress)
+ HWND hProgress,
+ LPWSTR lpStartParams)
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
DWORD dwMaxWait;
BOOL bRet = FALSE;
+ BOOL bWhiteSpace = TRUE;
+ LPWSTR lpChar;
+ DWORD dwArgsCount = 0;
+ LPCWSTR *lpArgsVector = NULL;
+
+ if (lpStartParams != NULL)
+ {
+ /* Count the number of arguments */
+ lpChar = lpStartParams;
+ while (*lpChar != 0)
+ {
+ if (iswspace(*lpChar))
+ {
+ bWhiteSpace = TRUE;
+ }
+ else
+ {
+ if (bWhiteSpace == TRUE)
+ {
+ dwArgsCount++;
+ bWhiteSpace = FALSE;
+ }
+ }
+
+ lpChar++;
+ }
+
+ /* Allocate the arguments vector and add one for the service name */
+ lpArgsVector = LocalAlloc(LMEM_FIXED, (dwArgsCount + 1) * sizeof(LPCWSTR));
+ if (!lpArgsVector)
+ return FALSE;
+
+ /* Make the service name the first argument */
+ lpArgsVector[0] = Info->pCurrentService->lpServiceName;
+
+ /* Fill the arguments vector */
+ dwArgsCount = 1;
+ bWhiteSpace = TRUE;
+ lpChar = lpStartParams;
+ while (*lpChar != 0)
+ {
+ if (iswspace(*lpChar))
+ {
+ *lpChar = 0;
+ bWhiteSpace = TRUE;
+ }
+ else
+ {
+ if (bWhiteSpace == TRUE)
+ {
+ lpArgsVector[dwArgsCount] = lpChar;
+ dwArgsCount++;
+ bWhiteSpace = FALSE;
+ }
+ }
+
+ lpChar++;
+ }
+ }
+
hSCManager = OpenSCManager(NULL,
NULL,
SC_MANAGER_CONNECT);
/* Start the service */
bRet = StartService(hService,
- 0,
- NULL);
+ dwArgsCount,
+ lpArgsVector);
if (!bRet && GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
{
/* If it's already running, just return TRUE */
CloseServiceHandle(hSCManager);
}
+ if (lpArgsVector)
+ LocalFree((LPVOID)lpArgsVector);
+
return bRet;
}
BOOL
-DoStart(PMAIN_WND_INFO Info)
+DoStart(PMAIN_WND_INFO Info, LPWSTR lpStartParams)
{
HWND hProgress;
BOOL bRet = FALSE;
InitializeProgressDialog(hProgress, Info->pCurrentService->lpServiceName);
/* Start the requested service */
- bRet = DoStartService(Info, hProgress);
+ bRet = DoStartService(Info, hProgress, lpStartParams);
/* Complete and destroy the progress bar */
DestroyProgressDialog(hProgress, bRet);
return bRet;
}
-