Author: ekohl
Date: Sun Jun 12 20:12:15 2016
New Revision: 71628
URL:
http://svn.reactos.org/svn/reactos?rev=71628&view=rev
Log:
[SC]
Merge the description functions into a single file.
Removed:
trunk/reactos/base/applications/sc/qdescription.c
Modified:
trunk/reactos/base/applications/sc/CMakeLists.txt
trunk/reactos/base/applications/sc/description.c
Modified: trunk/reactos/base/applications/sc/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/CMake…
==============================================================================
--- trunk/reactos/base/applications/sc/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sc/CMakeLists.txt [iso-8859-1] Sun Jun 12 20:12:15
2016
@@ -8,7 +8,6 @@
description.c
print.c
qc.c
- qdescription.c
qfailure.c
query.c
sc.c
Modified: trunk/reactos/base/applications/sc/description.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/descr…
==============================================================================
--- trunk/reactos/base/applications/sc/description.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sc/description.c [iso-8859-1] Sun Jun 12 20:12:15
2016
@@ -2,12 +2,92 @@
* PROJECT: ReactOS Services
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/applications/sc/description.c
- * PURPOSE: Change the service description
+ * PURPOSE: Query/Set the service description
* COPYRIGHT: Copyright 2016 Eric Kohl
*
*/
#include "sc.h"
+
+BOOL QueryDescription(LPCTSTR ServiceName)
+{
+ SC_HANDLE hManager = NULL;
+ SC_HANDLE hService = NULL;
+ BOOL bResult = TRUE;
+ DWORD cbBytesNeeded = 0;
+ LPSERVICE_DESCRIPTION pServiceDescription = NULL;
+
+#ifdef SCDBG
+ _tprintf(_T("service to show description - %s\n\n"), ServiceName);
+#endif
+
+ hManager = OpenSCManager(NULL,
+ NULL,
+ SC_MANAGER_CONNECT);
+ if (hManager == NULL)
+ {
+ bResult = FALSE;
+ goto done;
+ }
+
+ hService = OpenService(hManager, ServiceName, SERVICE_QUERY_CONFIG);
+ if (hService == NULL)
+ {
+ bResult = FALSE;
+ goto done;
+ }
+
+ if (!QueryServiceConfig2(hService,
+ SERVICE_CONFIG_DESCRIPTION,
+ NULL,
+ 0,
+ &cbBytesNeeded))
+ {
+ if (cbBytesNeeded == 0)
+ {
+ bResult = FALSE;
+ goto done;
+ }
+ }
+
+ pServiceDescription = HeapAlloc(GetProcessHeap(), 0, cbBytesNeeded);
+ if (pServiceDescription == NULL)
+ {
+ SetLastError(ERROR_OUTOFMEMORY);
+ bResult = FALSE;
+ goto done;
+ }
+
+ if (!QueryServiceConfig2(hService,
+ SERVICE_CONFIG_DESCRIPTION,
+ (LPBYTE)pServiceDescription,
+ cbBytesNeeded,
+ &cbBytesNeeded))
+ {
+ bResult = FALSE;
+ goto done;
+ }
+
+ _tprintf(_T("SERVICE_NAME: %s\n"), ServiceName);
+ _tprintf(_T(" DESCRIPTION : %s\n"),
+ (pServiceDescription->lpDescription) ?
pServiceDescription->lpDescription : _T(""));
+
+done:
+ if (bResult == FALSE)
+ ReportLastError();
+
+ if (pServiceDescription != NULL)
+ HeapFree(GetProcessHeap(), 0, pServiceDescription);
+
+ if (hService)
+ CloseServiceHandle(hService);
+
+ if (hManager)
+ CloseServiceHandle(hManager);
+
+ return bResult;
+}
+
BOOL SetDescription(LPCTSTR ServiceName, LPCTSTR Description)
{
Removed: trunk/reactos/base/applications/sc/qdescription.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/qdesc…
==============================================================================
--- trunk/reactos/base/applications/sc/qdescription.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sc/qdescription.c (removed)
@@ -1,89 +0,0 @@
-/*
- * PROJECT: ReactOS Services
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: base/applications/sc/qdescription.c
- * PURPOSE: Show the service description
- * COPYRIGHT: Copyright 2016 Eric Kohl
- *
- */
-
-#include "sc.h"
-
-BOOL QueryDescription(LPCTSTR ServiceName)
-{
- SC_HANDLE hManager = NULL;
- SC_HANDLE hService = NULL;
- BOOL bResult = TRUE;
- DWORD cbBytesNeeded = 0;
- LPSERVICE_DESCRIPTION pServiceDescription = NULL;
-
-#ifdef SCDBG
- _tprintf(_T("service to show description - %s\n\n"), ServiceName);
-#endif
-
- hManager = OpenSCManager(NULL,
- NULL,
- SC_MANAGER_CONNECT);
- if (hManager == NULL)
- {
- bResult = FALSE;
- goto done;
- }
-
- hService = OpenService(hManager, ServiceName, SERVICE_QUERY_CONFIG);
- if (hService == NULL)
- {
- bResult = FALSE;
- goto done;
- }
-
- if (!QueryServiceConfig2(hService,
- SERVICE_CONFIG_DESCRIPTION,
- NULL,
- 0,
- &cbBytesNeeded))
- {
- if (cbBytesNeeded == 0)
- {
- bResult = FALSE;
- goto done;
- }
- }
-
- pServiceDescription = HeapAlloc(GetProcessHeap(), 0, cbBytesNeeded);
- if (pServiceDescription == NULL)
- {
- SetLastError(ERROR_OUTOFMEMORY);
- bResult = FALSE;
- goto done;
- }
-
- if (!QueryServiceConfig2(hService,
- SERVICE_CONFIG_DESCRIPTION,
- (LPBYTE)pServiceDescription,
- cbBytesNeeded,
- &cbBytesNeeded))
- {
- bResult = FALSE;
- goto done;
- }
-
- _tprintf(_T("SERVICE_NAME: %s\n"), ServiceName);
- _tprintf(_T(" DESCRIPTION : %s\n"),
- (pServiceDescription->lpDescription) ?
pServiceDescription->lpDescription : _T(""));
-
-done:
- if (bResult == FALSE)
- ReportLastError();
-
- if (pServiceDescription != NULL)
- HeapFree(GetProcessHeap(), 0, pServiceDescription);
-
- if (hService)
- CloseServiceHandle(hService);
-
- if (hManager)
- CloseServiceHandle(hManager);
-
- return bResult;
-}