https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b3947d528316cd40705ad…
commit b3947d528316cd40705ad39a273925840a873a40
Author: Kyle Katarn <contact(a)kcsoftwares.com>
AuthorDate: Fri May 1 19:01:59 2020 +0200
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri May 1 19:01:59 2020 +0200
[SERVMAN] UI update and Error Management (#2653)
Purpose
=======
- Current design does not warn user nor logs DEBUG traces when Service Start/Stop
command fails or reach timeout.
- Current Service Start/Stop progress window are WS_EX_TOOLWINDOW which reduce
lisibility, is a ReactOS specificity without good reason.
Proposed changes
================
- DPRINT1 traces added on failure cases.
- Error Message box presented to user upon failure with explicit root cause
identification.
- Change Dialog definition to standard window.
---
base/applications/mscutils/servman/control.c | 32 +++++++--
base/applications/mscutils/servman/lang/bg-BG.rc | 1 -
base/applications/mscutils/servman/lang/cs-CZ.rc | 1 -
base/applications/mscutils/servman/lang/de-DE.rc | 1 -
base/applications/mscutils/servman/lang/el-GR.rc | 1 -
base/applications/mscutils/servman/lang/en-US.rc | 1 -
base/applications/mscutils/servman/lang/es-ES.rc | 1 -
base/applications/mscutils/servman/lang/fr-FR.rc | 1 -
base/applications/mscutils/servman/lang/he-IL.rc | 1 -
base/applications/mscutils/servman/lang/id-ID.rc | 1 -
base/applications/mscutils/servman/lang/it-IT.rc | 1 -
base/applications/mscutils/servman/lang/ja-JP.rc | 1 -
base/applications/mscutils/servman/lang/ko-KR.rc | 1 -
base/applications/mscutils/servman/lang/no-NO.rc | 1 -
base/applications/mscutils/servman/lang/pl-PL.rc | 1 -
base/applications/mscutils/servman/lang/ro-RO.rc | 1 -
base/applications/mscutils/servman/lang/ru-RU.rc | 1 -
base/applications/mscutils/servman/lang/sk-SK.rc | 1 -
base/applications/mscutils/servman/lang/sq-AL.rc | 1 -
base/applications/mscutils/servman/lang/sv-SE.rc | 1 -
base/applications/mscutils/servman/lang/th-TH.rc | 1 -
base/applications/mscutils/servman/lang/tr-TR.rc | 1 -
base/applications/mscutils/servman/lang/uk-UA.rc | 1 -
base/applications/mscutils/servman/lang/zh-CN.rc | 1 -
base/applications/mscutils/servman/lang/zh-TW.rc | 1 -
base/applications/mscutils/servman/precomp.h | 9 +--
base/applications/mscutils/servman/progress.c | 82 +++++++++++++++++++-----
base/applications/mscutils/servman/start.c | 27 ++++++--
base/applications/mscutils/servman/stop.c | 31 ++++++---
29 files changed, 138 insertions(+), 67 deletions(-)
diff --git a/base/applications/mscutils/servman/control.c
b/base/applications/mscutils/servman/control.c
index 08b88037f32..890bac61ae8 100644
--- a/base/applications/mscutils/servman/control.c
+++ b/base/applications/mscutils/servman/control.c
@@ -9,9 +9,12 @@
#include "precomp.h"
+#define NDEBUG
+#include <debug.h>
+
#define MAX_WAIT_TIME 30000
-BOOL
+DWORD
DoControlService(LPWSTR ServiceName,
HWND hProgress,
DWORD Control)
@@ -27,6 +30,7 @@ DoControlService(LPWSTR ServiceName,
DWORD MaxWait;
DWORD ReqState, i;
BOOL Result;
+ DWORD dwResult = ERROR_SUCCESS;
/* Set the state we're interested in */
switch (Control)
@@ -39,21 +43,23 @@ DoControlService(LPWSTR ServiceName,
break;
default:
/* Unhandled control code */
- return FALSE;
+ DPRINT1("Unknown control command: 0x%X\n", Control);
+ return ERROR_INVALID_SERVICE_CONTROL;
}
hSCManager = OpenSCManagerW(NULL,
NULL,
SC_MANAGER_CONNECT);
- if (!hSCManager) return FALSE;
+ if (!hSCManager) return GetLastError();
hService = OpenServiceW(hSCManager,
ServiceName,
SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE |
SERVICE_QUERY_STATUS);
if (!hService)
{
+ dwResult = GetLastError();
CloseServiceHandle(hSCManager);
- return FALSE;
+ return dwResult;
}
/* Send the control message to the service */
@@ -109,6 +115,8 @@ DoControlService(LPWSTR ServiceName,
&BytesNeeded))
{
/* Something went wrong... */
+ dwResult = GetLastError();
+ DPRINT1("QueryServiceStatusEx failed: %d\n", dwResult);
break;
}
@@ -123,23 +131,33 @@ DoControlService(LPWSTR ServiceName,
else
{
/* It's not, make sure we haven't exceeded our wait time */
- if(GetTickCount() >= StartTickCount + MaxWait)
+ if (GetTickCount() >= StartTickCount + MaxWait)
{
/* We have, give up */
+ DPRINT1("Timeout\n");
+ dwResult = ERROR_SERVICE_REQUEST_TIMEOUT;
break;
}
}
}
}
+ else
+ {
+ dwResult = GetLastError();
+ }
if (ServiceStatus.dwCurrentState == ReqState)
{
- Result = TRUE;
+ dwResult = ERROR_SUCCESS;
}
}
+ else
+ {
+ dwResult = GetLastError();
+ }
CloseServiceHandle(hService);
CloseServiceHandle(hSCManager);
- return Result;
+ return dwResult;
}
diff --git a/base/applications/mscutils/servman/lang/bg-BG.rc
b/base/applications/mscutils/servman/lang/bg-BG.rc
index 9135db9b84c..c19437e1089 100644
--- a/base/applications/mscutils/servman/lang/bg-BG.rc
+++ b/base/applications/mscutils/servman/lang/bg-BG.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Управление на услугите"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/cs-CZ.rc
b/base/applications/mscutils/servman/lang/cs-CZ.rc
index 2b7dc964d75..8632cf698f0 100644
--- a/base/applications/mscutils/servman/lang/cs-CZ.rc
+++ b/base/applications/mscutils/servman/lang/cs-CZ.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Ovldání služeb"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/de-DE.rc
b/base/applications/mscutils/servman/lang/de-DE.rc
index 0dbce992148..bb941ebd70f 100644
--- a/base/applications/mscutils/servman/lang/de-DE.rc
+++ b/base/applications/mscutils/servman/lang/de-DE.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Dienststeuerung"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/el-GR.rc
b/base/applications/mscutils/servman/lang/el-GR.rc
index 8bf7a616617..4eb8a250bec 100644
--- a/base/applications/mscutils/servman/lang/el-GR.rc
+++ b/base/applications/mscutils/servman/lang/el-GR.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Service Control"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/en-US.rc
b/base/applications/mscutils/servman/lang/en-US.rc
index 28f9896b168..272a73eb9f5 100644
--- a/base/applications/mscutils/servman/lang/en-US.rc
+++ b/base/applications/mscutils/servman/lang/en-US.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Service Control"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/es-ES.rc
b/base/applications/mscutils/servman/lang/es-ES.rc
index 8c34490d9de..1bf14df0b79 100644
--- a/base/applications/mscutils/servman/lang/es-ES.rc
+++ b/base/applications/mscutils/servman/lang/es-ES.rc
@@ -235,7 +235,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Control de servicios"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/fr-FR.rc
b/base/applications/mscutils/servman/lang/fr-FR.rc
index 92e0d7fdd80..38cd92cfad9 100644
--- a/base/applications/mscutils/servman/lang/fr-FR.rc
+++ b/base/applications/mscutils/servman/lang/fr-FR.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Contrôle du Service"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/he-IL.rc
b/base/applications/mscutils/servman/lang/he-IL.rc
index 459fb1e6a7b..af1c191532b 100644
--- a/base/applications/mscutils/servman/lang/he-IL.rc
+++ b/base/applications/mscutils/servman/lang/he-IL.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "בקרת שירות"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/id-ID.rc
b/base/applications/mscutils/servman/lang/id-ID.rc
index 268fc672b6f..22e9b39807f 100644
--- a/base/applications/mscutils/servman/lang/id-ID.rc
+++ b/base/applications/mscutils/servman/lang/id-ID.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Kontrol Layanan"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/it-IT.rc
b/base/applications/mscutils/servman/lang/it-IT.rc
index ec6c6d71784..8e6b295f31f 100644
--- a/base/applications/mscutils/servman/lang/it-IT.rc
+++ b/base/applications/mscutils/servman/lang/it-IT.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Controllo dei servizi"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/ja-JP.rc
b/base/applications/mscutils/servman/lang/ja-JP.rc
index aed6be21cfc..e21d46bdaab 100644
--- a/base/applications/mscutils/servman/lang/ja-JP.rc
+++ b/base/applications/mscutils/servman/lang/ja-JP.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "サービス コントロール"
FONT 9, "MS UI Gothic", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/ko-KR.rc
b/base/applications/mscutils/servman/lang/ko-KR.rc
index 2f5b09eb470..84036c6fe01 100644
--- a/base/applications/mscutils/servman/lang/ko-KR.rc
+++ b/base/applications/mscutils/servman/lang/ko-KR.rc
@@ -234,7 +234,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "서비스 컨트롤"
FONT 9, "굴림", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/no-NO.rc
b/base/applications/mscutils/servman/lang/no-NO.rc
index 8eefc7dec00..851e88b05b1 100644
--- a/base/applications/mscutils/servman/lang/no-NO.rc
+++ b/base/applications/mscutils/servman/lang/no-NO.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Tjeneste kontroll"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/pl-PL.rc
b/base/applications/mscutils/servman/lang/pl-PL.rc
index e1b4a08aeac..b96cce7d94a 100644
--- a/base/applications/mscutils/servman/lang/pl-PL.rc
+++ b/base/applications/mscutils/servman/lang/pl-PL.rc
@@ -242,7 +242,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Usługa kontrolna"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/ro-RO.rc
b/base/applications/mscutils/servman/lang/ro-RO.rc
index 838bc26bf9b..6740bedbb66 100644
--- a/base/applications/mscutils/servman/lang/ro-RO.rc
+++ b/base/applications/mscutils/servman/lang/ro-RO.rc
@@ -237,7 +237,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Control servicii"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/ru-RU.rc
b/base/applications/mscutils/servman/lang/ru-RU.rc
index 537ba738bef..8f504b4d404 100644
--- a/base/applications/mscutils/servman/lang/ru-RU.rc
+++ b/base/applications/mscutils/servman/lang/ru-RU.rc
@@ -232,7 +232,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Управление службами"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/sk-SK.rc
b/base/applications/mscutils/servman/lang/sk-SK.rc
index 77b2c3b87ec..f5c88129fcf 100644
--- a/base/applications/mscutils/servman/lang/sk-SK.rc
+++ b/base/applications/mscutils/servman/lang/sk-SK.rc
@@ -237,7 +237,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Service Control"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/sq-AL.rc
b/base/applications/mscutils/servman/lang/sq-AL.rc
index bde90df05f5..4f9c936ed2e 100644
--- a/base/applications/mscutils/servman/lang/sq-AL.rc
+++ b/base/applications/mscutils/servman/lang/sq-AL.rc
@@ -237,7 +237,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Kontrolli i shërbimeve"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/sv-SE.rc
b/base/applications/mscutils/servman/lang/sv-SE.rc
index 37bec57e0b8..2cb32144080 100644
--- a/base/applications/mscutils/servman/lang/sv-SE.rc
+++ b/base/applications/mscutils/servman/lang/sv-SE.rc
@@ -239,7 +239,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Tjänst kontroll"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/th-TH.rc
b/base/applications/mscutils/servman/lang/th-TH.rc
index f46dd572817..23706f70e6a 100644
--- a/base/applications/mscutils/servman/lang/th-TH.rc
+++ b/base/applications/mscutils/servman/lang/th-TH.rc
@@ -240,7 +240,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "ตัวควบคุมบริการ"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/tr-TR.rc
b/base/applications/mscutils/servman/lang/tr-TR.rc
index 4c1c00b93d1..fad8766630b 100644
--- a/base/applications/mscutils/servman/lang/tr-TR.rc
+++ b/base/applications/mscutils/servman/lang/tr-TR.rc
@@ -234,7 +234,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Hizmet Denetimi"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/uk-UA.rc
b/base/applications/mscutils/servman/lang/uk-UA.rc
index 54512dabfc0..a4fe3d509f7 100644
--- a/base/applications/mscutils/servman/lang/uk-UA.rc
+++ b/base/applications/mscutils/servman/lang/uk-UA.rc
@@ -240,7 +240,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "Управління службами"
FONT 8, "MS Shell Dlg", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/zh-CN.rc
b/base/applications/mscutils/servman/lang/zh-CN.rc
index ae578a2117b..df562a2a091 100644
--- a/base/applications/mscutils/servman/lang/zh-CN.rc
+++ b/base/applications/mscutils/servman/lang/zh-CN.rc
@@ -234,7 +234,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "服务控制"
FONT 9, "宋体", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/lang/zh-TW.rc
b/base/applications/mscutils/servman/lang/zh-TW.rc
index a29a41f31a6..27ca6c40bd5 100644
--- a/base/applications/mscutils/servman/lang/zh-TW.rc
+++ b/base/applications/mscutils/servman/lang/zh-TW.rc
@@ -234,7 +234,6 @@ IDD_DLG_PROGRESS DIALOGEX 6, 6, 255, 89
CAPTION "服務控制"
FONT 9, "新細明體", 0, 0
STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME
-EXSTYLE WS_EX_TOOLWINDOW
BEGIN
CONTROL "", IDC_SERVCON_PROGRESS, "msctls_progress32",
0x50000000, 8, 46, 238, 13
LTEXT "", IDC_SERVCON_INFO, 8, 5, 236, 11
diff --git a/base/applications/mscutils/servman/precomp.h
b/base/applications/mscutils/servman/precomp.h
index 5ec27109f61..d070bbc4dc3 100644
--- a/base/applications/mscutils/servman/precomp.h
+++ b/base/applications/mscutils/servman/precomp.h
@@ -7,9 +7,11 @@
#include <windef.h>
#include <winbase.h>
+#include <winerror.h>
#include <wingdi.h>
#include <winsvc.h>
#include <wincon.h>
+
#include <shlobj.h>
#include <commdlg.h>
#include <strsafe.h>
@@ -100,9 +102,9 @@ VOID ListViewSelectionChanged(PMAIN_WND_INFO Info, LPNMLISTVIEW
pnmv);
BOOL CreateListView(PMAIN_WND_INFO Info);
/* start / stop / control */
-BOOL DoStartService(LPWSTR ServiceName, HANDLE hProgress, LPWSTR lpStartParams);
-BOOL DoStopService(LPWSTR ServiceName, HANDLE hProgress);
-BOOL DoControlService(LPWSTR ServiceName, HWND hProgress, DWORD Control);
+DWORD DoStartService(LPWSTR ServiceName, HANDLE hProgress, LPWSTR lpStartParams);
+DWORD DoStopService(LPWSTR ServiceName, HANDLE hProgress);
+DWORD DoControlService(LPWSTR ServiceName, HWND hProgress, DWORD Control);
/* progress.c */
#define DEFAULT_STEP 0
@@ -122,7 +124,6 @@ BOOL RefreshServiceList(PMAIN_WND_INFO Info);
BOOL UpdateServiceStatus(ENUM_SERVICE_STATUS_PROCESS* pService);
BOOL GetServiceList(PMAIN_WND_INFO Info);
-
/* propsheet.c */
typedef struct _SERVICEPROPSHEET
{
diff --git a/base/applications/mscutils/servman/progress.c
b/base/applications/mscutils/servman/progress.c
index cf5fe784300..fa3a82a3ab5 100644
--- a/base/applications/mscutils/servman/progress.c
+++ b/base/applications/mscutils/servman/progress.c
@@ -26,6 +26,25 @@ typedef struct _PROGRESS_DATA
} PROGRESS_DATA, *PPROGRESS_DATA;
+VOID ShowError(DWORD dwLastError)
+{
+ LPWSTR lpMsg;
+
+ if (!FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwLastError,
+ LANG_USER_DEFAULT,
+ (LPWSTR)&lpMsg,
+ 0, NULL))
+ {
+ return;
+ }
+
+ MessageBoxW(NULL, lpMsg, NULL, MB_OK | MB_ICONERROR);
+ LocalFree(lpMsg);
+}
static VOID
ResetProgressDialog(HWND hDlg,
@@ -67,6 +86,7 @@ ResetProgressDialog(HWND hDlg,
unsigned int __stdcall ActionThread(void* Param)
{
PPROGRESS_DATA ProgressData = (PPROGRESS_DATA)Param;
+ DWORD dwResult;
if (ProgressData->Action == ACTION_START)
{
@@ -76,13 +96,18 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_START);
/* Start the service */
- if (DoStartService(ProgressData->ServiceName,
- ProgressData->hProgress,
- ProgressData->Param))
+ dwResult = DoStartService(ProgressData->ServiceName,
+ ProgressData->hProgress,
+ ProgressData->Param);
+ if (dwResult == ERROR_SUCCESS)
{
/* We're done, slide the progress bar up to the top */
CompleteProgressBar(ProgressData->hProgress);
}
+ else
+ {
+ ShowError(dwResult);
+ }
}
else if (ProgressData->Action == ACTION_STOP || ProgressData->Action ==
ACTION_RESTART)
{
@@ -108,11 +133,16 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_STOP);
/* Stop the requested service */
- if (DoStopService(ProgressData->ServiceName,
- ProgressData->hProgress))
+ dwResult = DoStopService(ProgressData->ServiceName,
+ ProgressData->hProgress);
+ if (dwResult == ERROR_SUCCESS)
{
CompleteProgressBar(ProgressData->hProgress);
}
+ else
+ {
+ ShowError(dwResult);
+ }
/* Move onto the next string */
while (*lpStr != L'\0')
@@ -124,11 +154,16 @@ unsigned int __stdcall ActionThread(void* Param)
ProgressData->ServiceName,
IDS_PROGRESS_INFO_STOP);
- if (DoStopService(ProgressData->ServiceName,
- ProgressData->hProgress))
+ dwResult = DoStopService(ProgressData->ServiceName,
+ ProgressData->hProgress);
+ if (dwResult == ERROR_SUCCESS)
{
CompleteProgressBar(ProgressData->hProgress);
}
+ else
+ {
+ ShowError(dwResult);
+ }
/* If this was a restart, we'll need to start the service back up */
@@ -140,13 +175,18 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_START);
/* Start the service */
- if (DoStartService(ProgressData->ServiceName,
- ProgressData->hProgress,
- NULL))
+ dwResult = DoStartService(ProgressData->ServiceName,
+ ProgressData->hProgress,
+ NULL);
+ if (dwResult == ERROR_SUCCESS)
{
/* We're done, slide the progress bar up to the top */
CompleteProgressBar(ProgressData->hProgress);
}
+ else
+ {
+ ShowError(dwResult);
+ }
}
}
else if (ProgressData->Action == ACTION_PAUSE)
@@ -157,13 +197,18 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_PAUSE);
/* Pause the service */
- if (DoControlService(ProgressData->ServiceName,
- ProgressData->hProgress,
- SERVICE_CONTROL_PAUSE))
+ dwResult = DoControlService(ProgressData->ServiceName,
+ ProgressData->hProgress,
+ SERVICE_CONTROL_PAUSE);
+ if (dwResult == ERROR_SUCCESS)
{
/* We're done, slide the progress bar up to the top */
CompleteProgressBar(ProgressData->hProgress);
}
+ else
+ {
+ ShowError(dwResult);
+ }
}
else if (ProgressData->Action == ACTION_RESUME)
{
@@ -173,13 +218,18 @@ unsigned int __stdcall ActionThread(void* Param)
IDS_PROGRESS_INFO_RESUME);
/* resume the service */
- if (DoControlService(ProgressData->ServiceName,
- ProgressData->hProgress,
- SERVICE_CONTROL_CONTINUE))
+ dwResult = DoControlService(ProgressData->ServiceName,
+ ProgressData->hProgress,
+ SERVICE_CONTROL_CONTINUE);
+ if (dwResult == ERROR_SUCCESS)
{
/* We're done, slide the progress bar up to the top */
CompleteProgressBar(ProgressData->hProgress);
}
+ else
+ {
+ ShowError(dwResult);
+ }
}
diff --git a/base/applications/mscutils/servman/start.c
b/base/applications/mscutils/servman/start.c
index ac237e2d28b..eb931875c6f 100644
--- a/base/applications/mscutils/servman/start.c
+++ b/base/applications/mscutils/servman/start.c
@@ -9,9 +9,12 @@
#include "precomp.h"
+#define NDEBUG
+#include <debug.h>
+
#define MAX_WAIT_TIME 30000
-BOOL
+DWORD
DoStartService(LPWSTR ServiceName,
HANDLE hProgress,
LPWSTR lpStartParams)
@@ -29,6 +32,7 @@ DoStartService(LPWSTR ServiceName,
BOOL bWhiteSpace = TRUE;
LPWSTR lpChar;
DWORD dwArgsCount = 0;
+ DWORD dwResult = ERROR_SUCCESS;
LPCWSTR *lpArgsVector = NULL;
if (lpStartParams != NULL)
@@ -59,7 +63,7 @@ DoStartService(LPWSTR ServiceName,
*/
lpArgsVector = LocalAlloc(LMEM_FIXED, dwArgsCount * sizeof(LPCWSTR));
if (!lpArgsVector)
- return FALSE;
+ return GetLastError();
/* Fill the arguments vector */
dwArgsCount = 0;
@@ -91,9 +95,10 @@ DoStartService(LPWSTR ServiceName,
SC_MANAGER_CONNECT);
if (!hSCManager)
{
+ dwResult = GetLastError();
if (lpArgsVector)
LocalFree((LPVOID)lpArgsVector);
- return FALSE;
+ return dwResult;
}
hService = OpenServiceW(hSCManager,
@@ -101,10 +106,11 @@ DoStartService(LPWSTR ServiceName,
SERVICE_START | SERVICE_QUERY_STATUS);
if (!hService)
{
+ dwResult = GetLastError();
CloseServiceHandle(hSCManager);
if (lpArgsVector)
LocalFree((LPVOID)lpArgsVector);
- return FALSE;
+ return dwResult;
}
/* Start the service */
@@ -167,6 +173,8 @@ DoStartService(LPWSTR ServiceName,
&BytesNeeded))
{
/* Something went wrong... */
+ dwResult = GetLastError();
+ DPRINT1("QueryServiceStatusEx failed: %d\n", dwResult);
break;
}
@@ -183,24 +191,29 @@ DoStartService(LPWSTR ServiceName,
if (GetTickCount() >= StartTickCount + MaxWait)
{
/* We have, give up */
+ DPRINT1("Timeout\n");
+ dwResult = ERROR_SERVICE_REQUEST_TIMEOUT;
break;
}
}
}
}
+ else
+ {
+ dwResult = GetLastError();
+ }
if (ServiceStatus.dwCurrentState == SERVICE_RUNNING)
{
- Result = TRUE;
+ dwResult = ERROR_SUCCESS;
}
}
CloseServiceHandle(hService);
-
CloseServiceHandle(hSCManager);
if (lpArgsVector)
LocalFree((LPVOID)lpArgsVector);
- return Result;
+ return dwResult;
}
diff --git a/base/applications/mscutils/servman/stop.c
b/base/applications/mscutils/servman/stop.c
index 50c0a376fb2..c4a346dd003 100644
--- a/base/applications/mscutils/servman/stop.c
+++ b/base/applications/mscutils/servman/stop.c
@@ -9,9 +9,12 @@
#include "precomp.h"
+#define NDEBUG
+#include <debug.h>
+
#define MAX_WAIT_TIME 30000
-BOOL
+DWORD
DoStopService(_In_z_ LPWSTR ServiceName,
_In_opt_ HANDLE hProgress)
{
@@ -22,21 +25,21 @@ DoStopService(_In_z_ LPWSTR ServiceName,
DWORD StartTime;
DWORD WaitTime;
DWORD Timeout;
- BOOL bRet = FALSE;
-
-
+ DWORD dwResult = ERROR_SUCCESS;
+
hSCManager = OpenSCManagerW(NULL,
NULL,
SC_MANAGER_CONNECT);
- if (!hSCManager) return FALSE;
+ if (!hSCManager) return GetLastError();
hService = OpenServiceW(hSCManager,
ServiceName,
SERVICE_STOP | SERVICE_QUERY_STATUS);
if (!hService)
{
+ dwResult = GetLastError();
CloseServiceHandle(hSCManager);
- return FALSE;
+ return dwResult;
}
if (hProgress)
@@ -90,21 +93,31 @@ DoStopService(_In_z_ LPWSTR ServiceName,
if (GetTickCount() - StartTime > Timeout)
{
/* Yep, give up */
+ DPRINT1("Timeout\n");
+ dwResult = ERROR_SERVICE_REQUEST_TIMEOUT;
break;
}
}
+ else
+ {
+ dwResult = GetLastError();
+ DPRINT1("QueryServiceStatusEx failed: %d\n", dwResult);
+ }
}
/* If the service is stopped, return TRUE */
if (ServiceStatus.dwCurrentState == SERVICE_STOPPED)
{
- bRet = TRUE;
+ dwResult = ERROR_SUCCESS;
}
}
+ else
+ {
+ dwResult = GetLastError();
+ }
CloseServiceHandle(hService);
-
CloseServiceHandle(hSCManager);
- return bRet;
+ return dwResult;
}