BOOL DoStart(PMAIN_WND_INFO Info, LPWSTR lpStartParams) { HWND hProgress; BOOL bRet = FALSE; /* Create a progress window to track the progress of the stopping service */ hProgress = CreateProgressDialog(Info->hMainWnd, IDS_PROGRESS_INFO_START); if (hProgress) { /* Set the service name and reset the progress bag */ InitializeProgressDialog(hProgress, Info->pCurrentService->lpServiceName); /* Start the requested service */ bRet = DoStartService(Info, hProgress, lpStartParams); /* Complete and destroy the progress bar */ DestroyProgressDialog(hProgress, bRet); } return bRet; }
BOOL DoResume(PMAIN_WND_INFO Info) { HWND hProgress; BOOL bRet = FALSE; /* Create a progress window to track the progress of the resuming service */ hProgress = CreateProgressDialog(Info->hMainWnd, IDS_PROGRESS_INFO_RESUME); if (hProgress) { /* Set the service name and reset the progress bag */ InitializeProgressDialog(hProgress, Info->pCurrentService->lpServiceName); /* Resume the requested service */ bRet = DoControl(Info, hProgress, SERVICE_CONTROL_CONTINUE); /* Complete and destroy the progress bar */ DestroyProgressDialog(hProgress, bRet); } return bRet; }
BOOL DoStop(PMAIN_WND_INFO pInfo) { HWND hProgress; LPWSTR lpServiceList; BOOL bRet = FALSE; BOOL bStopMainService = TRUE; if (pInfo) { /* Does the service have any dependent services which need stopping first */ 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)pInfo) == IDOK) { /* Create a progress window to track the progress of the stopping services */ hProgress = CreateProgressDialog(pInfo->hMainWnd, IDS_PROGRESS_INFO_STOP); /* Stop all the dependant services */ StopDependantServices(pInfo, lpServiceList, hProgress); /* Now stop the requested one */ bRet = StopService(pInfo, pInfo->pCurrentService->lpServiceName, hProgress); /* We've already stopped the main service, don't try to stop it again */ bStopMainService = FALSE; if (hProgress) { /* Complete and destroy the progress bar */ DestroyProgressDialog(hProgress, TRUE); } } else { /* Don't stop the main service if the user selected not to */ bStopMainService = FALSE; } HeapFree(GetProcessHeap(), 0, lpServiceList); } /* If the service has no running dependents, then we stop it here */ if (bStopMainService) { /* Create a progress window to track the progress of the stopping service */ hProgress = CreateProgressDialog(pInfo->hMainWnd, 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); } } } return bRet; }