| 474 | } |
| 475 | |
| 476 | LRESULT CServiceTable::OnServiceStop(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { |
| 477 | int selected = m_Table.data.selected; |
| 478 | ATLASSERT(selected >= 0); |
| 479 | auto& svc = m_Table.data.info[selected]; |
| 480 | |
| 481 | ATLASSERT(svc.GetStatusProcess().CurrentState == ServiceState::Running); |
| 482 | |
| 483 | auto service = Service::Open(svc.GetName(), ServiceAccessMask::Stop | ServiceAccessMask::QueryStatus); |
| 484 | if (service == nullptr) { |
| 485 | AtlMessageBox(*this, L"Failed to open service", IDS_TITLE, MB_ICONERROR); |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | if (!service->Stop()) { |
| 490 | AtlMessageBox(*this, L"Failed to stop service", IDS_TITLE, MB_ICONERROR); |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | CProgressDlg dlg; |
| 495 | dlg.ShowCancelButton(false); |
| 496 | dlg.SetMessageText((L"Stopping service " + svc.GetName() + L"...").c_str()); |
| 497 | dlg.SetProgressMarquee(true); |
| 498 | dlg.SetTimerCallback([&]() { |
| 499 | service->Refresh(svc); |
| 500 | if (svc.GetStatusProcess().CurrentState == ServiceState::Stopped) |
| 501 | dlg.Close(); |
| 502 | }, 500); |
| 503 | dlg.DoModal(); |
| 504 | Refresh(); |
| 505 | |
| 506 | return 0; |
| 507 | } |
| 508 | |
| 509 | LRESULT CServiceTable::OnServicePause(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { |
| 510 | int selected = m_Table.data.selected; |
nothing calls this directly
no test coverage detected