📄 writeerrorlog.cpp
字号:
// WriteErrorLog.cpp
//
#include "stdafx.h"
#include "WriteErrorLog.h"
/////////////////////////////////////////////////////////////////////////////
// CWriteErrorLog
/////////////////////////////////////////////////////////////////////////////
// CHeelApp construction
CWriteErrorLog::CWriteErrorLog()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
BOOL CWriteErrorLog::WriteLogFile(CString m_strErrorInfo)
{
FILE *stream;
CString strTime;
CString strFileName;
CString strTemp;
CString strWriteInfo;
CTime timeCurrent = CTime::GetCurrentTime(); // 获取系统日期
int iYear = timeCurrent.GetYear(); // 获取年份
int iMonth = timeCurrent.GetMonth(); // 获取当前月份
int iDay = timeCurrent.GetDay(); // 获得几号
int iHour = timeCurrent.GetHour(); // 获取当前为几时
int iMinute = timeCurrent.GetMinute(); // 获取分钟
int iSecond = timeCurrent.GetSecond(); // 获取秒
strFileName.Format("%04d-%02d-%02d.txt", iYear, iMonth, iDay);
strTime.Format("%04d-%02d-%02d %02d:%02d:%02d", iYear, iMonth, iDay, iHour, iMinute, iSecond);
strWriteInfo = strTime + " " + m_strErrorInfo;
/* Open file in text mode: */
if( (stream = fopen( strFileName, "a" )) != NULL )
{
//把文件的位置指针移到文件尾
fseek(stream, 0L, SEEK_END);
/* Write 25 characters to stream */
fwrite( strWriteInfo, strWriteInfo.GetLength(), 1, stream );
strTemp = "\n";
fwrite( strTemp, strTemp.GetLength(), 1, stream );
//获取文件长度
//length=ftell(stream);
fclose( stream );
return true;
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -