Add functionality for changing the service config. unused at the moment.

svn path=/trunk/; revision=28644
This commit is contained in:
Ged Murphy 2007-08-29 09:42:31 +00:00
parent 8da0438ac6
commit a4ebd5b085
2 changed files with 46 additions and 3 deletions

View file

@ -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);

View file

@ -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;
}