mirror of
https://github.com/reactos/reactos.git
synced 2024-07-29 23:58:44 +00:00
[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. svn path=/trunk/; revision=53121
This commit is contained in:
parent
3e02029bbf
commit
6e4f110888
|
@ -469,7 +469,7 @@ MainWndCommand(PMAIN_WND_INFO Info,
|
||||||
|
|
||||||
case ID_START:
|
case ID_START:
|
||||||
{
|
{
|
||||||
if (DoStart(Info))
|
if (DoStart(Info, NULL))
|
||||||
{
|
{
|
||||||
UpdateServiceStatus(Info->pCurrentService);
|
UpdateServiceStatus(Info->pCurrentService);
|
||||||
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
|
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
|
||||||
|
@ -500,7 +500,7 @@ MainWndCommand(PMAIN_WND_INFO Info,
|
||||||
case ID_RESTART:
|
case ID_RESTART:
|
||||||
if (DoStop(Info))
|
if (DoStop(Info))
|
||||||
{
|
{
|
||||||
DoStart(Info);
|
DoStart(Info, NULL);
|
||||||
UpdateServiceStatus(Info->pCurrentService);
|
UpdateServiceStatus(Info->pCurrentService);
|
||||||
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
|
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
|
||||||
SetMenuAndButtonStates(Info);
|
SetMenuAndButtonStates(Info);
|
||||||
|
|
|
@ -79,7 +79,7 @@ VOID ListViewSelectionChanged(PMAIN_WND_INFO Info, LPNMLISTVIEW pnmv);
|
||||||
BOOL CreateListView(PMAIN_WND_INFO Info);
|
BOOL CreateListView(PMAIN_WND_INFO Info);
|
||||||
|
|
||||||
/* start */
|
/* start */
|
||||||
BOOL DoStart(PMAIN_WND_INFO Info);
|
BOOL DoStart(PMAIN_WND_INFO Info, LPWSTR lpStartParams);
|
||||||
|
|
||||||
/* stop */
|
/* stop */
|
||||||
typedef struct _STOP_INFO
|
typedef struct _STOP_INFO
|
||||||
|
|
|
@ -48,6 +48,9 @@ SetButtonStates(PSERVICEPROPSHEET dlgInfo,
|
||||||
EnableWindow (hButton, TRUE);
|
EnableWindow (hButton, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hButton = GetDlgItem(hwndDlg, IDC_START_PARAM);
|
||||||
|
EnableWindow(hButton, (State == SERVICE_STOPPED));
|
||||||
|
|
||||||
/* set the main toolbar */
|
/* set the main toolbar */
|
||||||
SetMenuAndButtonStates(dlgInfo->Info);
|
SetMenuAndButtonStates(dlgInfo->Info);
|
||||||
}
|
}
|
||||||
|
@ -248,6 +251,27 @@ SaveDlgInfo(PSERVICEPROPSHEET dlgInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* General Property dialog callback.
|
* General Property dialog callback.
|
||||||
* Controls messages to the General dialog
|
* Controls messages to the General dialog
|
||||||
|
@ -293,13 +317,7 @@ GeneralPageProc(HWND hwndDlg,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_START:
|
case IDC_START:
|
||||||
if (DoStart(dlgInfo->Info))
|
OnStart(hwndDlg, dlgInfo);
|
||||||
{
|
|
||||||
UpdateServiceStatus(dlgInfo->pService);
|
|
||||||
ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS);
|
|
||||||
SetButtonStates(dlgInfo, hwndDlg);
|
|
||||||
SetServiceStatusText(dlgInfo, hwndDlg);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_STOP:
|
case IDC_STOP:
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
DoStartService(PMAIN_WND_INFO Info,
|
DoStartService(PMAIN_WND_INFO Info,
|
||||||
HWND hProgress)
|
HWND hProgress,
|
||||||
|
LPWSTR lpStartParams)
|
||||||
{
|
{
|
||||||
SC_HANDLE hSCManager;
|
SC_HANDLE hSCManager;
|
||||||
SC_HANDLE hService;
|
SC_HANDLE hService;
|
||||||
|
@ -23,6 +24,66 @@ DoStartService(PMAIN_WND_INFO Info,
|
||||||
DWORD dwMaxWait;
|
DWORD dwMaxWait;
|
||||||
BOOL bRet = FALSE;
|
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,
|
hSCManager = OpenSCManager(NULL,
|
||||||
NULL,
|
NULL,
|
||||||
SC_MANAGER_CONNECT);
|
SC_MANAGER_CONNECT);
|
||||||
|
@ -41,8 +102,8 @@ DoStartService(PMAIN_WND_INFO Info,
|
||||||
|
|
||||||
/* Start the service */
|
/* Start the service */
|
||||||
bRet = StartService(hService,
|
bRet = StartService(hService,
|
||||||
0,
|
dwArgsCount,
|
||||||
NULL);
|
lpArgsVector);
|
||||||
if (!bRet && GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
|
if (!bRet && GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
|
||||||
{
|
{
|
||||||
/* If it's already running, just return TRUE */
|
/* If it's already running, just return TRUE */
|
||||||
|
@ -121,11 +182,14 @@ DoStartService(PMAIN_WND_INFO Info,
|
||||||
CloseServiceHandle(hSCManager);
|
CloseServiceHandle(hSCManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lpArgsVector)
|
||||||
|
LocalFree(lpArgsVector);
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
DoStart(PMAIN_WND_INFO Info)
|
DoStart(PMAIN_WND_INFO Info, LPWSTR lpStartParams)
|
||||||
{
|
{
|
||||||
HWND hProgress;
|
HWND hProgress;
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
|
@ -139,7 +203,7 @@ DoStart(PMAIN_WND_INFO Info)
|
||||||
InitializeProgressDialog(hProgress, Info->pCurrentService->lpServiceName);
|
InitializeProgressDialog(hProgress, Info->pCurrentService->lpServiceName);
|
||||||
|
|
||||||
/* Start the requested service */
|
/* Start the requested service */
|
||||||
bRet = DoStartService(Info, hProgress);
|
bRet = DoStartService(Info, hProgress, lpStartParams);
|
||||||
|
|
||||||
/* Complete and destroy the progress bar */
|
/* Complete and destroy the progress bar */
|
||||||
DestroyProgressDialog(hProgress, bRet);
|
DestroyProgressDialog(hProgress, bRet);
|
||||||
|
|
Loading…
Reference in a new issue