CFile m_fileTestLog;
来源:互联网 发布:vb与西门子plc通讯 编辑:程序博客网 时间:2024/06/07 01:28
CFile m_fileTestLog;
void CEventsLog::AddTestLog(CString strContent)
{
//TRACE(strContent);
DebugMsg(strContent);
CSingleLock TestLogLock(&m_TestLogLock);
m_TestLogLock.Lock();
CFileException e;
try //////////////////////////////////////////
{
//
COleDateTime dtCurrent = COleDateTime::GetCurrentTime();
CString strTemp = dtCurrent.Format("%Y-%m-%d %H:%M:%S >>");
strContent = strTemp + strContent;
if (m_bRebuildTest)//重建文件
{
if (!m_fileTestLog.Open("C://ICTTestLog.TXT",CFile::modeCreate | CFile::modeWrite | CFile::modeRead) )
{
return ;
}
m_bRebuildTest = FALSE ;
}
else if (!m_fileTestLog.Open("C://ICTTestLog.TXT", CFile::modeWrite | CFile::modeRead))
{
if (!m_fileTestLog.Open("C://ICTTestLog.TXT",CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate | CFile::modeRead) )
{
return ;
}
}
m_fileTestLog.Seek(0,CFile::end);
int nLength = strContent.GetLength();
if (nLength>0)
{
m_fileTestLog.Write((LPCTSTR)strContent,nLength);
}
char chEnter[2];
chEnter[0]=0x0d;
chEnter[1]=0x0a;
m_fileTestLog.Write(chEnter,2);
m_nWriteTestfileLogTimes++;
//////检查文件大小
if (m_nWriteTestfileLogTimes>100)//每写一百次检查一次
{
m_nWriteTestfileLogTimes = 0 ;
CFileStatus status;
if( m_fileTestLog.GetStatus( status ) )
{
if ( status.m_size > 1024*1024*20 ) m_bRebuildTest = TRUE; //
}
}
m_fileTestLog.Close();
}///////////////////////////////////////////////
catch( CException* e )
{
::Sleep(100);
e->Delete();
//m_SystemExceptionLock.Unlock;
//AfxMessageBox( _T("错误!"), MB_ICONEXCLAMATION );
}
catch(...)
{
//g_EventsLog.AddSystemException("...");
//m_SystemExceptionLock.Unlock;
}
m_TestLogLock.Unlock();
}
- CFile m_fileTestLog;
- CFile...
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile
- CFile类
- CFile详解
- CFile源码
- 有一种生涯,叫 PSD2HTML
- Xhtml 代码嵌套查看辅助工具
- 使用整洁的HTML标记构建页面
- 36个引人注目的导航菜单(上)
- 一起感受HTML5和CSS3的能量
- CFile m_fileTestLog;
- 不依赖于DLL就能工作的全局钩子
- 动态页面静态化技术
- HTTP Headers 入门
- 用Excel VBA选择文件、打开文件
- 【常用自定义函数001】VBA高容错性地打开文件
- [求助]怎样一次打开多个文件
- Excel-VBA操作文件四大方法(一)
- 学习c++的五十条忠告