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; }
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; }