// CTOR of HTTP Server session ServerSession::ServerSession() { ASSERT(g_session == nullptr); ReadRegistrySettings(); CreateLogfile(); InitializeCriticalSection(&m_lock); }
UINT CSAStatusLog::Init(const TCHAR *pLogFilename) { UINT ErrorCode; // get application path TCHAR szAppPath[MAX_PATH]={0}; if (! GetModuleFileName(NULL,szAppPath,MAX_PATH)) { OutputDebugStringW(L"GetModuleFileName Error"); return GetLastError(); } // Call to "PathRemoveFileSpec". get app path. if (!PathRemoveFileSpec(szAppPath)) { OutputDebugStringW(L"PathRemoveFileSpec Error"); return GetLastError(); } // Create Log Dir TCHAR szLogDir[MAX_PATH]={0}; _stprintf_s(szLogDir,_T("%s\\Log"),szAppPath); BOOL rt = CreateDirectory(szLogDir,NULL); if (!rt && GetLastError() != 183) { OutputDebugStringW(L"CreateDirectory Error"); int err = GetLastError(); _tprintf(_T("Create directory %s error(%d).\r\n"),szLogDir,err); return err; } SYSTEMTIME sys; GetLocalTime( &sys ); _stprintf_s(m_szLogfile,_T("C:\\Log\\%s_%02d%02d%02d_%02d%02d.Log"),pLogFilename,sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute); OutputDebugStringW(m_szLogfile); // create log file ErrorCode = CreateLogfile(m_hFile); if (ErrorCode) { OutputDebugStringW(L"CreateLogfile Error"); return ErrorCode; } m_bEnable = TRUE; return 0; }
int __stdcall WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, char* lpCmdLine, int nCmdShow) { QCoreApplication::setOrganizationName( "jesperhansen" ); QCoreApplication::setOrganizationDomain( "jesperhansen.net" ); QCoreApplication::setApplicationName( "syncclient" ); CreateLogfile(); #ifdef WINDOWS ExceptionHandler::registerExceptionHandler(); #endif ClientApp app( 1, &lpCmdLine ); int nRet = 0; app.exec(); #ifdef WINDOWS ExceptionHandler::unRegisterExceptionHandler(); #endif CloseLogfile(); return nRet; }
int main( int argc, char **argv ) { QCoreApplication::setOrganizationName( "jesperhansen" ); QCoreApplication::setOrganizationDomain( "jesperhansen.net" ); QCoreApplication::setApplicationName( "syncclient" ); CreateLogfile(); #ifdef WINDOWS ExceptionHandler::registerExceptionHandler(); #endif ClientApp app( argc, argv ); int nRet = app.exec(); #ifdef WINDOWS ExceptionHandler::unRegisterExceptionHandler(); #endif CloseLogfile(); return nRet; }