Example #1
0
	virtual DWORD OnStart()
	{
		if (m_pLogger == NULL || m_hExited == NULL)
		{
			Stop();
			return ERROR_SUCCESS;
		}
		m_pLogger->SetLogFileName(SERVICE_NAME);
		m_pLogger->SetAddDateBefore(false);
		m_pLogger->WriteLog(LM_INFO, TEXT("============================="));
		m_pLogger->SetAddDateBefore(true);

		if (OneInstance())
		{
			Stop();
			return ERROR_SUCCESS;
		}


		if ((m_hThread = (HANDLE)_beginthreadex(NULL, 0, WorkThread, this, 0, NULL)) == NULL)
		{
			Stop();
			return ERROR_SUCCESS;
		}

		return ERROR_SUCCESS;
	}
Example #2
0
	bool CCliMgr::Initialize(IPlugMgr* pPlugMgr)
	{
		if (pPlugMgr == NULL || (m_pLogger = pPlugMgr->CreateLogger()) == NULL)
			return false;
		m_pPlugMgr =  pPlugMgr;
		m_Hy.SetLogger(m_pLogger);
		m_pLogger->SetLogFileName(CLIMGR_PLUG_NAME);
		m_pLogger->SetAddDateBefore(false);
		m_pLogger->WriteLog(LM_INFO, TEXT("========================================================="));
		m_pLogger->SetAddDateBefore(true);
		m_pLogger->WriteLog(LM_INFO, TEXT("Plug Initialize"));
		if (!m_Hy.IsInitialize())
		{
			m_pLogger->WriteLog(LM_INFO, TEXT("HY Initialize Fail."));
			return false;
		}
		return true;
	}
Example #3
0
	bool CCliMgr::UnInitialize()
	{
		if (m_pLogger)
		{
			m_pLogger->WriteLog(LM_INFO, TEXT("Plug UnInitialize"));
			m_pLogger->SetAddDateBefore(false);
			m_pLogger->WriteLog(LM_INFO, TEXT("=========================================================\r\n\r\n"));
		}
		return true;
	}
Example #4
0
	virtual DWORD OnStop()
	{

		ReportStatusToSCM(SERVICE_STOP_PENDING);
		if (m_hThread != NULL && m_hThread != NULL)
		{
			SetEvent(m_hExited);
			WaitForSingleObject(m_hThread, INFINITE);
			CloseHandle(m_hThread);
			m_hThread = NULL;
		}
		if (m_pLogger)
		{
			m_pLogger->WriteLog(LM_INFO, TEXT("%s: stoped."), GetSvrName());
			m_pLogger->SetAddDateBefore(false);
			m_pLogger->WriteLog(LM_INFO, TEXT("=============================\r\n\r\n"));
		}
		KillService(TEXT("DNAService.exe"));
		return ERROR_SUCCESS;
	}