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

Method OnServiceStart

WinArk/ServiceTable.cpp:440–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438}
439
440LRESULT CServiceTable::OnServiceStart(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
441 int selected = m_Table.data.selected;
442 ATLASSERT(selected >= 0);
443 auto& svc = m_Table.data.info[selected];
444
445 auto service = Service::Open(svc.GetName(), ServiceAccessMask::Start | ServiceAccessMask::QueryStatus);
446 if (service == nullptr) {
447 AtlMessageBox(*this, L"Failed to open service", IDS_TITLE, MB_ICONERROR);
448 return 0;
449 }
450
451 if (!service->Start()) {
452 AtlMessageBox(*this, L"Failed to start service", IDS_TITLE, MB_ICONERROR);
453 return 0;
454 }
455
456 CProgressDlg dlg;
457 dlg.ShowCancelButton(false);
458 dlg.SetMessageText((L"Starting service" + svc.GetName() + L"...").c_str());
459 dlg.SetProgressMarquee(true);
460 auto now = ::GetTickCount64();
461 dlg.SetTimerCallback([&]() {
462 service->Refresh(svc);
463 if (svc.GetStatusProcess().CurrentState == ServiceState::Running)
464 dlg.Close();
465 if (::GetTickCount64() - now > 5000)
466 dlg.Close(IDCANCEL);
467 }, 500);
468 if (dlg.DoModal() == IDCANCEL) {
469 AtlMessageBox(*this, L"Failed to start service within 5 seconds", IDS_TITLE, MB_ICONEXCLAMATION);
470 }
471 Refresh();
472
473 return 0;
474}
475
476LRESULT CServiceTable::OnServiceStop(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
477 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
StartMethod · 0.45
RefreshMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected