diff --git a/reactos/base/applications/mscutils/servman/control.c b/reactos/base/applications/mscutils/servman/control.c
index e08dafab86a..e87649b0da1 100644
--- a/reactos/base/applications/mscutils/servman/control.c
+++ b/reactos/base/applications/mscutils/servman/control.c
@@ -9,7 +9,7 @@
#include "precomp.h"
-static BOOL
+BOOL
Control(PMAIN_WND_INFO Info,
HWND hProgDlg,
DWORD Control)
@@ -114,25 +114,6 @@ Control(PMAIN_WND_INFO Info,
}
-BOOL DoStop(PMAIN_WND_INFO Info)
-{
- BOOL ret = FALSE;
- HWND hProgDlg;
-
- hProgDlg = CreateProgressDialog(Info->hMainWnd,
- Info->pCurrentService->lpServiceName,
- IDS_PROGRESS_INFO_STOP);
- if (hProgDlg)
- {
- ret = Control(Info,
- hProgDlg,
- SERVICE_CONTROL_STOP);
-
- DestroyWindow(hProgDlg);
- }
-
- return ret;
-}
BOOL DoPause(PMAIN_WND_INFO Info)
{
@@ -154,6 +135,7 @@ BOOL DoPause(PMAIN_WND_INFO Info)
return ret;
}
+
BOOL DoResume(PMAIN_WND_INFO Info)
{
BOOL ret = FALSE;
@@ -173,4 +155,3 @@ BOOL DoResume(PMAIN_WND_INFO Info)
return ret;
}
-
diff --git a/reactos/base/applications/mscutils/servman/precomp.h b/reactos/base/applications/mscutils/servman/precomp.h
index 9cab84f46cd..eaf6eb1f5cf 100644
--- a/reactos/base/applications/mscutils/servman/precomp.h
+++ b/reactos/base/applications/mscutils/servman/precomp.h
@@ -75,6 +75,7 @@ BOOL CreateListView(PMAIN_WND_INFO Info);
BOOL DoStart(PMAIN_WND_INFO Info);
/* control */
+BOOL Control(PMAIN_WND_INFO Info, HWND hProgDlg, DWORD Control);
BOOL DoStop(PMAIN_WND_INFO Info);
BOOL DoPause(PMAIN_WND_INFO Info);
BOOL DoResume(PMAIN_WND_INFO Info);
diff --git a/reactos/base/applications/mscutils/servman/servman.rbuild b/reactos/base/applications/mscutils/servman/servman.rbuild
index 4c3ad80d440..c3937c93758 100644
--- a/reactos/base/applications/mscutils/servman/servman.rbuild
+++ b/reactos/base/applications/mscutils/servman/servman.rbuild
@@ -27,6 +27,7 @@
query.c
servman.c
start.c
+ stop.c
servman.rc
precomp.h
diff --git a/reactos/base/applications/mscutils/servman/stop.c b/reactos/base/applications/mscutils/servman/stop.c
new file mode 100644
index 00000000000..ba8c2a66374
--- /dev/null
+++ b/reactos/base/applications/mscutils/servman/stop.c
@@ -0,0 +1,96 @@
+/*
+ * PROJECT: ReactOS Services
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: base/applications/mscutils/servman/stop.c
+ * PURPOSE: Stops running a service
+ * COPYRIGHT: Copyright 2006-2007 Ged Murphy
+ *
+ */
+
+#include "precomp.h"
+
+BOOL
+DoStop(PMAIN_WND_INFO Info)
+{
+ SC_HANDLE hSCManager = NULL;
+ SC_HANDLE hSc = NULL;
+ LPQUERY_SERVICE_CONFIG lpServiceConfig = NULL;
+ HWND hProgDlg;
+ DWORD BytesNeeded = 0;
+ BOOL ret = FALSE;
+
+ hSCManager = OpenSCManager(NULL,
+ NULL,
+ SC_MANAGER_ENUMERATE_SERVICE);
+ if (hSCManager == NULL)
+ {
+ GetError();
+ return FALSE;
+ }
+
+ hSc = OpenService(hSCManager,
+ Info->pCurrentService->lpServiceName,
+ SERVICE_QUERY_CONFIG);
+ if (hSc)
+ {
+ if (!QueryServiceConfig(hSc,
+ lpServiceConfig,
+ 0,
+ &BytesNeeded))
+ {
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ lpServiceConfig = (LPQUERY_SERVICE_CONFIG)HeapAlloc(ProcessHeap,
+ 0,
+ BytesNeeded);
+ if (lpServiceConfig == NULL)
+ goto cleanup;
+
+ if (QueryServiceConfig(hSc,
+ lpServiceConfig,
+ BytesNeeded,
+ &BytesNeeded))
+ {
+ if (lpServiceConfig->lpDependencies)
+ {
+ TCHAR str[500];
+
+ _sntprintf(str, 499, _T("%s depends on this service, implement the dialog to allow closing of other services"),
+ lpServiceConfig->lpDependencies);
+ MessageBox(NULL, str, NULL, 0);
+
+ //FIXME: open 'stop other services' box
+ }
+ else
+ {
+ hProgDlg = CreateProgressDialog(Info->hMainWnd,
+ Info->pCurrentService->lpServiceName,
+ IDS_PROGRESS_INFO_STOP);
+ if (hProgDlg)
+ {
+ ret = Control(Info,
+ hProgDlg,
+ SERVICE_CONTROL_STOP);
+
+ DestroyWindow(hProgDlg);
+ }
+ }
+
+ HeapFree(ProcessHeap,
+ 0,
+ lpServiceConfig);
+
+ lpServiceConfig = NULL;
+ }
+ }
+ }
+ }
+
+cleanup:
+ if (hSCManager != NULL)
+ CloseServiceHandle(hSCManager);
+ if (hSc != NULL)
+ CloseServiceHandle(hSc);
+
+ return ret;
+}