Display all service dependants which need stopping

svn path=/trunk/; revision=44955
This commit is contained in:
Ged Murphy 2010-01-05 19:19:06 +00:00
parent 8320c599d1
commit 24e15791e0
3 changed files with 78 additions and 19 deletions

View file

@ -44,6 +44,8 @@ typedef struct _MAIN_WND_INFO
BOOL bInMenuLoop;
BOOL bIsUserAnAdmin;
PVOID pTag;
} MAIN_WND_INFO, *PMAIN_WND_INFO;

View file

@ -119,6 +119,7 @@ DoStop(PMAIN_WND_INFO pInfo)
HWND hProgress;
LPWSTR lpServiceList;
BOOL bRet = FALSE;
BOOL bStop = TRUE;
if (pInfo)
{
@ -129,33 +130,44 @@ DoStop(PMAIN_WND_INFO pInfo)
lpServiceList = GetListOfServicesToStop(pInfo->pCurrentService->lpServiceName);
if (lpServiceList)
{
/* Tag the service list to the main wnd info */
pInfo->pTag = (PVOID)lpServiceList;
/* List them and ask the user if they want to stop them */
if (DialogBoxParamW(hInstance,
MAKEINTRESOURCEW(IDD_DLG_DEPEND_STOP),
pInfo->hMainWnd,
StopDependsDialogProc,
(LPARAM)lpServiceList) == IDOK)
MAKEINTRESOURCEW(IDD_DLG_DEPEND_STOP),
pInfo->hMainWnd,
StopDependsDialogProc,
(LPARAM)pInfo) == IDOK)
{
/* Stop all the dependant services */
StopDependantServices(pInfo, pInfo->pCurrentService->lpServiceName);
}
else
{
/* Don't stop the main service if the user selected not to */
bStop = FALSE;
}
}
}
/* Create a progress window to track the progress of the stopping service */
hProgress = CreateProgressDialog(pInfo->hMainWnd,
pInfo->pCurrentService->lpServiceName,
IDS_PROGRESS_INFO_STOP);
/* Stop the requested service */
bRet = StopService(pInfo,
pInfo->pCurrentService->lpServiceName,
hProgress);
if (hProgress)
if (bStop)
{
/* Complete and destroy the progress bar */
DestroyProgressDialog(hProgress, TRUE);
/* Create a progress window to track the progress of the stopping service */
hProgress = CreateProgressDialog(pInfo->hMainWnd,
pInfo->pCurrentService->lpServiceName,
IDS_PROGRESS_INFO_STOP);
/* Stop the requested service */
bRet = StopService(pInfo,
pInfo->pCurrentService->lpServiceName,
hProgress);
if (hProgress)
{
/* Complete and destroy the progress bar */
DestroyProgressDialog(hProgress, TRUE);
}
}
}

View file

@ -125,10 +125,49 @@ GetListOfServicesToStop(LPWSTR lpServiceName)
}
static VOID
AddServiceNamesToStop(HWND hServiceListBox,
LPWSTR lpServiceList)
{
LPQUERY_SERVICE_CONFIG lpServiceConfig;
LPWSTR lpStr;
lpStr = lpServiceList;
/* Loop through all the services in the list */
while (TRUE)
{
/* Break when we hit the double null */
if (*lpStr == L'\0' && *(lpStr + 1) == L'\0')
break;
/* If this isn't our first time in the loop we'll
have been left on a null char */
if (*lpStr == L'\0')
lpStr++;
/* Get the service's display name */
lpServiceConfig = GetServiceConfig(lpStr);
if (lpServiceConfig)
{
/* Add the service to the listbox */
SendMessageW(hServiceListBox,
LB_ADDSTRING,
0,
(LPARAM)lpServiceConfig->lpDisplayName);
}
/* Move onto the next string */
while (*lpStr != L'\0')
lpStr++;
}
}
static BOOL
DoInitDependsDialog(PMAIN_WND_INFO pInfo,
HWND hDlg)
{
HWND hServiceListBox;
LPWSTR lpPartialStr, lpStr;
DWORD fullLen;
HICON hIcon = NULL;
@ -196,8 +235,14 @@ DoInitDependsDialog(PMAIN_WND_INFO pInfo,
lpPartialStr);
}
/* FIXME: Load the list of services which need stopping */
/* Display the list of services which need stopping */
hServiceListBox = GetDlgItem(hDlg,
IDC_STOP_DEPENDS_LB);
if (hServiceListBox)
{
AddServiceNamesToStop(hServiceListBox,
(LPWSTR)pInfo->pTag);
}
}
return bRet;