如果你的软件需要打日志那就可以用
void CMe::WriteLog(CString logName, CString msg, bool isAdd)
{
USES_CONVERSION;
FILE *fp;
logName = L"temp/" + logName;
char *filename = W2A(logName);
if (isAdd)
{
if ((fp = fopen(filename, "a")) == NULL)
{
return;
}
}
else
{
if ((fp = fopen(filename, "w")) == NULL)
{
return;
}
}
if (fp == NULL)
return;
CTime tt = CTime::GetCurrentTime();
//作为Log文件,经常要给每条Log打时间戳,时间格式可自由定义,
//这里的格式如:2010-June-10 Thursday, 15:58:12
CString msLine = tt.Format(L"[%Y%B%d,%H:%M:%S]:");
fprintf(fp, W2A(msLine + msg + L"\n"));
fclose(fp);
return;
}