MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / OnServiceStop

Method OnServiceStop

WinArk/ServiceTable.cpp:476–507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

474}
475
476LRESULT 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
509LRESULT CServiceTable::OnServicePause(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
510 int selected = m_Table.data.selected;

Callers

nothing calls this directly

Calls 8

GetNameMethod · 0.80
ShowCancelButtonMethod · 0.80
SetMessageTextMethod · 0.80
SetProgressMarqueeMethod · 0.80
SetTimerCallbackMethod · 0.80
StopMethod · 0.45
RefreshMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected