123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include "stdafx.h"
- #include "Lock.h"
- TCHAR g_szModuleFilePath[MAX_PATH + 1] = {0};
- CLock g_loglock;
- void WriteLogin(CString str)
- {
- CAutoLock autolock(&g_loglock);
- try
- {
- CStdioFile fp;
-
- CString path = g_szModuleFilePath;
- path += _T("备份模块.txt");
- if (::PathFileExists(path))
- {
- #ifndef _UNICODE
- fp.Open(path, CFile::modeWrite);
- #else
- fp.Open(path, CFile::modeWrite | CFile::typeBinary | CFile::typeText);
- #endif
- int length = fp.GetLength();
- if (length > 1024 * 1024)
- {
- fp.Close();
- ::DeleteFile(path);
- return;
- }
- fp.SeekToEnd();
- }
- else
- {
- #ifndef _UNICODE
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- #else
- fp.Open(path, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
- #endif
- }
- CString strMsg = _T("");
- strMsg.Format(_T("%s%s\n"), CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S ")), str);
- fp.WriteString(strMsg);
- fp.Close();
- }
- catch (...)
- {
- }
- }
|