当前位置: 首页>>代码示例>>C++>>正文


C++ CNTService::OnStop方法代码示例

本文整理汇总了C++中CNTService::OnStop方法的典型用法代码示例。如果您正苦于以下问题:C++ CNTService::OnStop方法的具体用法?C++ CNTService::OnStop怎么用?C++ CNTService::OnStop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CNTService的用法示例。


在下文中一共展示了CNTService::OnStop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Handler

// static member function (callback) to handle commands from the
// service control manager
void WINAPI CNTService::Handler(DWORD dwOpcode)
{
    // Get a pointer to the object
    CNTService* pService = m_pThis;
    
    pService->DebugMsg("CNTService::Handler(%lu)", dwOpcode);
    switch (dwOpcode) {
    case SERVICE_CONTROL_STOP: // 1
        pService->SetStatus(SERVICE_STOP_PENDING);
        pService->OnStop();
        pService->m_bIsRunning = FALSE;
        pService->LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_STOPPED);
		pService->SetStatus(SERVICE_STOPPED);
        break;

    case SERVICE_CONTROL_PAUSE: // 2
        pService->OnSignal();
		pService->OnPause();
        break;

    case SERVICE_CONTROL_CONTINUE: // 3
        pService->OnSignal();
		pService->OnContinue();
        break;

    case SERVICE_CONTROL_INTERROGATE: // 4
        pService->OnInterrogate();
		pService->OnSignal();
        break;

    case SERVICE_CONTROL_SHUTDOWN: // 5
		pService->DebugMsg("CNTService::Handler - Calling Shutdown");
        pService->SetStatus(SERVICE_STOP_PENDING);
        pService->OnShutdown();
        pService->m_bIsRunning = FALSE;
        pService->LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_STOPPED);
		pService->SetStatus(SERVICE_STOPPED);
		pService->m_bIsRunning = FALSE;
        break;

    default:
		pService->OnSignal();
        if (dwOpcode >= SERVICE_CONTROL_USER) {
            if (!pService->OnUserControl(dwOpcode)) {
                pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_BADREQUEST);
            }
        } else {
            pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_BADREQUEST);
        }
        break;
    }

    // Report current status
    pService->DebugMsg("Updating status (%lu, %lu)",
                       pService->m_hServiceStatus,
                       pService->m_Status.dwCurrentState);
    ::SetServiceStatus(pService->m_hServiceStatus, &pService->m_Status);
}
开发者ID:WuerthPhoenix,项目名称:safed,代码行数:60,代码来源:NTService.cpp

示例2: Handler

// static member function (callback) to handle commands from the
// service control manager
void CNTService::Handler(DWORD dwOpcode)
{
#ifdef _DEBUG
  cout << "NTService: handling service control manager command:";
#endif
    // Get a pointer to the object
    CNTService* pService = m_pThis;
    
    switch (dwOpcode) {
    case SERVICE_CONTROL_STOP: // 1
#ifdef _DEBUG
      cout << "stop" << endl;
#endif
        pService->SetStatus(SERVICE_STOP_PENDING);
        pService->OnStop();
        pService->m_bIsRunning = FALSE;
        pService->LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_STOPPED);
        break;

    case SERVICE_CONTROL_PAUSE: // 2
#ifdef _DEBUG
      cout << "pause" << endl;
#endif
        pService->OnPause();
        break;

    case SERVICE_CONTROL_CONTINUE: // 3
#ifdef _DEBUG
      cout << "continue" << endl;
#endif
        pService->OnContinue();
        break;

    case SERVICE_CONTROL_INTERROGATE: // 4
#ifdef _DEBUG
      cout << "interrogate" << endl;
#endif
        pService->OnInterrogate();
        break;

    case SERVICE_CONTROL_SHUTDOWN: // 5
#ifdef _DEBUG
      cout << "shutdown" << endl;
#endif
        pService->OnShutdown();
        break;

    default:
        if (dwOpcode >= SERVICE_CONTROL_USER) {
#ifdef _DEBUG
      cout << "user control" << endl;
#endif
            if (!pService->OnUserControl(dwOpcode)) {
                pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_BADREQUEST);
            }
        } else {
#ifdef _DEBUG
      cout << "unknown" << endl;
#endif
            pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_BADREQUEST);
        }
        break;
    }

    // Report current status
    ::SetServiceStatus(pService->m_hServiceStatus, &pService->m_Status);
}
开发者ID:bigmacd,项目名称:common,代码行数:69,代码来源:NTService.cpp


注:本文中的CNTService::OnStop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。