diff --git a/reactos/base/applications/mscutils/servman/precomp.h b/reactos/base/applications/mscutils/servman/precomp.h index a2f222ee916..9edc653b566 100644 --- a/reactos/base/applications/mscutils/servman/precomp.h +++ b/reactos/base/applications/mscutils/servman/precomp.h @@ -44,6 +44,8 @@ typedef struct _MAIN_WND_INFO BOOL bInMenuLoop; BOOL bIsUserAnAdmin; + PVOID pTag; + } MAIN_WND_INFO, *PMAIN_WND_INFO; diff --git a/reactos/base/applications/mscutils/servman/stop.c b/reactos/base/applications/mscutils/servman/stop.c index 51e7117d549..fe8980c6c3a 100644 --- a/reactos/base/applications/mscutils/servman/stop.c +++ b/reactos/base/applications/mscutils/servman/stop.c @@ -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); + } } } diff --git a/reactos/base/applications/mscutils/servman/stop_dependencies.c b/reactos/base/applications/mscutils/servman/stop_dependencies.c index 5820a34d9bf..53860d004e1 100644 --- a/reactos/base/applications/mscutils/servman/stop_dependencies.c +++ b/reactos/base/applications/mscutils/servman/stop_dependencies.c @@ -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;