Author: ekohl
Date: Sun Aug 7 19:10:12 2011
New Revision: 53121
URL:
http://svn.reactos.org/svn/reactos?rev=53121&view=rev
Log:
[SERVMAN]
- When a service gets started, read the start parameters from the edit control and pass
them to StartService.
- Disable the start parameter edit control while a service is running.
Modified:
trunk/reactos/base/applications/mscutils/servman/mainwnd.c
trunk/reactos/base/applications/mscutils/servman/precomp.h
trunk/reactos/base/applications/mscutils/servman/propsheet_general.c
trunk/reactos/base/applications/mscutils/servman/start.c
Modified: trunk/reactos/base/applications/mscutils/servman/mainwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/mainwnd.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mscutils/servman/mainwnd.c [iso-8859-1] Sun Aug 7
19:10:12 2011
@@ -469,7 +469,7 @@
case ID_START:
{
- if (DoStart(Info))
+ if (DoStart(Info, NULL))
{
UpdateServiceStatus(Info->pCurrentService);
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
@@ -500,7 +500,7 @@
case ID_RESTART:
if (DoStop(Info))
{
- DoStart(Info);
+ DoStart(Info, NULL);
UpdateServiceStatus(Info->pCurrentService);
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
SetMenuAndButtonStates(Info);
Modified: trunk/reactos/base/applications/mscutils/servman/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mscutils/servman/precomp.h [iso-8859-1] Sun Aug 7
19:10:12 2011
@@ -79,7 +79,7 @@
BOOL CreateListView(PMAIN_WND_INFO Info);
/* start */
-BOOL DoStart(PMAIN_WND_INFO Info);
+BOOL DoStart(PMAIN_WND_INFO Info, LPWSTR lpStartParams);
/* stop */
typedef struct _STOP_INFO
Modified: trunk/reactos/base/applications/mscutils/servman/propsheet_general.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/propsheet_general.c [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/mscutils/servman/propsheet_general.c [iso-8859-1] Sun
Aug 7 19:10:12 2011
@@ -48,6 +48,9 @@
EnableWindow (hButton, TRUE);
}
+ hButton = GetDlgItem(hwndDlg, IDC_START_PARAM);
+ EnableWindow(hButton, (State == SERVICE_STOPPED));
+
/* set the main toolbar */
SetMenuAndButtonStates(dlgInfo->Info);
}
@@ -244,6 +247,27 @@
HeapFree(ProcessHeap,
0,
pServiceConfig);
+ }
+}
+
+
+static
+VOID
+OnStart(HWND hwndDlg,
+ PSERVICEPROPSHEET dlgInfo)
+{
+ WCHAR szStartParams[256];
+ LPWSTR lpStartParams = NULL;
+
+ if (GetDlgItemText(hwndDlg, IDC_START_PARAM, szStartParams, 256) > 0)
+ lpStartParams = szStartParams;
+
+ if (DoStart(dlgInfo->Info, lpStartParams))
+ {
+ UpdateServiceStatus(dlgInfo->pService);
+ ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS);
+ SetButtonStates(dlgInfo, hwndDlg);
+ SetServiceStatusText(dlgInfo, hwndDlg);
}
}
@@ -293,13 +317,7 @@
break;
case IDC_START:
- if (DoStart(dlgInfo->Info))
- {
- UpdateServiceStatus(dlgInfo->pService);
- ChangeListViewText(dlgInfo->Info, dlgInfo->pService,
LVSTATUS);
- SetButtonStates(dlgInfo, hwndDlg);
- SetServiceStatusText(dlgInfo, hwndDlg);
- }
+ OnStart(hwndDlg, dlgInfo);
break;
case IDC_STOP:
Modified: trunk/reactos/base/applications/mscutils/servman/start.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/start.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mscutils/servman/start.c [iso-8859-1] Sun Aug 7
19:10:12 2011
@@ -11,7 +11,8 @@
static BOOL
DoStartService(PMAIN_WND_INFO Info,
- HWND hProgress)
+ HWND hProgress,
+ LPWSTR lpStartParams)
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
@@ -22,6 +23,66 @@
DWORD dwWaitTime;
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,
@@ -41,8 +102,8 @@
/* 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 */
@@ -121,11 +182,14 @@
CloseServiceHandle(hSCManager);
}
+ if (lpArgsVector)
+ LocalFree(lpArgsVector);
+
return bRet;
}
BOOL
-DoStart(PMAIN_WND_INFO Info)
+DoStart(PMAIN_WND_INFO Info, LPWSTR lpStartParams)
{
HWND hProgress;
BOOL bRet = FALSE;
@@ -139,7 +203,7 @@
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);