From a4ebd5b0858eec2750cb2e4ad9d6b9caa3f86b75 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Wed, 29 Aug 2007 09:42:31 +0000 Subject: [PATCH] Add functionality for changing the service config. unused at the moment. svn path=/trunk/; revision=28644 --- .../applications/mscutils/servman/precomp.h | 2 +- .../applications/mscutils/servman/query.c | 47 ++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/reactos/base/applications/mscutils/servman/precomp.h b/reactos/base/applications/mscutils/servman/precomp.h index b245043b7e9..d6a996a53b0 100644 --- a/reactos/base/applications/mscutils/servman/precomp.h +++ b/reactos/base/applications/mscutils/servman/precomp.h @@ -74,7 +74,7 @@ VOID CompleteProgressBar(HWND hProgDlg); /* query.c */ ENUM_SERVICE_STATUS_PROCESS* GetSelectedService(PMAIN_WND_INFO Info); LPQUERY_SERVICE_CONFIG GetServiceConfig(LPTSTR lpServiceName); -VOID SetServiceConfig(LPQUERY_SERVICE_CONFIG); +BOOL SetServiceConfig(LPQUERY_SERVICE_CONFIG pServiceConfig, LPTSTR lpServiceName, LPTSTR lpPassword); LPTSTR GetServiceDescription(LPTSTR lpServiceName); LPTSTR GetExecutablePath(LPTSTR lpServiceName); BOOL RefreshServiceList(PMAIN_WND_INFO Info); diff --git a/reactos/base/applications/mscutils/servman/query.c b/reactos/base/applications/mscutils/servman/query.c index 8442576ff61..357898c0cae 100644 --- a/reactos/base/applications/mscutils/servman/query.c +++ b/reactos/base/applications/mscutils/servman/query.c @@ -90,10 +90,53 @@ cleanup: } -VOID -SetServiceConfig(LPQUERY_SERVICE_CONFIG pServiceConfig) +BOOL +SetServiceConfig(LPQUERY_SERVICE_CONFIG pServiceConfig, + LPTSTR lpServiceName, + LPTSTR lpPassword) { + SC_HANDLE hSCManager; + SC_HANDLE hSc; + SC_LOCK scLock; + BOOL bRet = FALSE; + hSCManager = OpenSCManager(NULL, + NULL, + SC_MANAGER_LOCK); + if (hSCManager) + { + scLock = LockServiceDatabase(hSCManager); + if (scLock) + { + hSc = OpenService(hSCManager, + lpServiceName, + SERVICE_QUERY_CONFIG); + if (hSc) + { + if (ChangeServiceConfig(hSc, + pServiceConfig->dwServiceType, + pServiceConfig->dwStartType, + pServiceConfig->dwErrorControl, + pServiceConfig->lpBinaryPathName, + pServiceConfig->lpLoadOrderGroup, + &pServiceConfig->dwTagId, + pServiceConfig->lpDependencies, + pServiceConfig->lpServiceStartName, + lpPassword, + pServiceConfig->lpDisplayName)) + { + bRet = TRUE; + } + } + + UnlockServiceDatabase(scLock); + } + } + + if (!bRet) + GetError(); + + return bRet; }