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


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

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


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

示例1: ServiceMain

void CNTService::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
    // Get a pointer to the C++ object
    CNTService* pService = m_pThis;

    pService->DebugMsg("Entering CNTService::ServiceMain()");
    // Register the control request handler
    pService->m_Status.dwCurrentState = SERVICE_START_PENDING;
    pService->m_hServiceStatus = RegisterServiceCtrlHandlerA(pService->m_szServiceName,
                                                           Handler);
    if (pService->m_hServiceStatus == NULL) {
        pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_CTRLHANDLERNOTINSTALLED);
        return;
    }

    // Start the initialisation
    if (pService->Initialize()) {

        // Do the real work. 
        // When the Run function returns, the service has stopped.
        pService->m_bIsRunning = TRUE;
        pService->m_Status.dwWin32ExitCode = 0;
        pService->m_Status.dwCheckPoint = 0;
        pService->m_Status.dwWaitHint = 0;
        pService->Run();
    }

    // Tell the service manager we are stopped
    pService->SetStatus(SERVICE_STOPPED);

    pService->DebugMsg("Leaving CNTService::ServiceMain()");
}
开发者ID:sg-first,项目名称:Process-prevent-killed,代码行数:32,代码来源:NTService.cpp

示例2: ServiceMain

void CNTService::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
    // Get a pointer to the C++ object
    CNTService* pService = m_pThis;
    
    pService->DebugMsg(_("Entering CNTService::ServiceMain()"));

    // Register the control request handler
    pService->m_Status.dwCurrentState = SERVICE_START_PENDING;
    pService->m_hServiceStatus = RegisterServiceCtrlHandler(pService->m_szServiceName,
                                                           Handler);
    if ( pService->m_hServiceStatus == NULL ) {
        pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_CTRLHANDLERNOTINSTALLED);
        return;
    }

    // Start the initialisation
    if ( pService->Initialize() )  {
        // Do the real work. 
        // When the Run function returns, the service has stopped.
        pService->m_bIsRunning = true;
        pService->m_Status.dwWin32ExitCode = 0;
        pService->m_Status.dwCheckPoint = 0;
        pService->m_Status.dwWaitHint = 0;
        pService->Run();
    }


	// Now wait for threads to exit.
	DWORD dwWaitRes;
    if ( ( dwWaitRes = WaitForMultipleObjects( MAX_THREADS, ghThreads, TRUE, 3000 ) )
					== WAIT_OBJECT_0 ) {
		// This is OK! Nothing more to do.....
		;
	}
    else if ( ( dwWaitRes == WAIT_FAILED ) || ( dwWaitRes == WAIT_ABANDONED ) ) {
		// We failed to kill the threads we have to
		// abort anyway but we tell the world that we do so....
		pService->DebugMsg(_("Failed to terminate all threads in CNTService::ServiceMain()"));
	}    

	// close the event handle and the thread handle
	CloseHandle( ghStopEvent );
	for (int i=0; i<MAX_THREADS; i++ ) {
		if ( ghThreads[i] ) {
			CloseHandle( ghThreads[i] );	 
		}
	}

    // Tell the service manager we are stopped
    pService->SetStatus( SERVICE_STOPPED );

    pService->DebugMsg(_("Leaving CNTService::ServiceMain()"));
}
开发者ID:BlueAndi,项目名称:vscp_software,代码行数:54,代码来源:ntservice.cpp

示例3: ServiceMain

void CNTService::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
    CNTService* pService = m_pThis;
    
    pService->m_Status.dwCurrentState = SERVICE_START_PENDING;
    pService->m_hServiceStatus = RegisterServiceCtrlHandler(pService->m_szServiceName, Handler);
    if (pService->m_hServiceStatus != NULL) {
        if (pService->Initialize()) {
            pService->m_bIsRunning = TRUE;
            pService->m_Status.dwWin32ExitCode = 0;
            pService->m_Status.dwCheckPoint = 0;
            pService->m_Status.dwWaitHint = 0;
            pService->Run();
        }
        pService->SetStatus(SERVICE_STOPPED);
    }
}
开发者ID:Apercu,项目名称:iphone-sms,代码行数:17,代码来源:example_nt_service.cpp

示例4: ServiceMain

// static member function (callback)
void CNTService::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
#ifdef _DEBUG
    cout << "in NTService ServiceMain" << endl;
#endif
    // Get a pointer to the C++ object
    CNTService* pService = m_pThis;
    
    // Register the control request handler
    pService->m_Status.dwCurrentState = SERVICE_START_PENDING;
    pService->m_hServiceStatus = RegisterServiceCtrlHandler(pService->m_szServiceName,
                                                           Handler);
    if (pService->m_hServiceStatus == NULL) {
        pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_CTRLHANDLERNOTINSTALLED);
#ifdef _DEBUG
    cout << "NTService:could not register control request handler" << endl;
#endif
        return;
    }

    // Start the initialisation
    if (pService->Initialize()) {

#ifdef _DEBUG
    cout << "NTService: Initialization was successful - ready to go" << endl;
#endif
        // Do the real work. 
        // When the Run function returns, the service has stopped.
        pService->m_bIsRunning = TRUE;
        pService->m_Status.dwWin32ExitCode = 0;
        pService->m_Status.dwCheckPoint = 0;
        pService->m_Status.dwWaitHint = 0;
        pService->Run();
    }

#ifdef _DEBUG
    cout << "NTService: Initialize failed!" << endl;
#endif

    // Tell the service manager we are stopped
    pService->SetStatus(SERVICE_STOPPED);

}
开发者ID:bigmacd,项目名称:common,代码行数:44,代码来源:NTService.cpp


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