MFC 运行日志

void WriteLog(CString Msg)
{
 CTime tm =CTime::GetCurrentTime();
 CString str = tm.Format("%Y-%m-%d-%H-%M-%S");
 CString sPage = str + "     "+Msg+"r"+"n";
 CFile logfile (_T("C:\RunLog.log"), CFile::modeNoTruncate|CFile::modeReadWrite|CFile::modeCreate);
 logfile.SeekToEnd();
 logfile.Write(sPage,sPage.GetLength());
 logfile.Flush();
 logfile.Close();
}

 

posted @ 2016-02-25 16:18  風行  阅读(652)  评论(0编辑  收藏  举报