用ATL写文件
2015-09-27 18:17
190 查看
#include "stdafx.h" #include "Translate.h" #include <AtlStr.h> #include <AtlFile.h> #include <AtlTime.h> // CTranslate void writelogA(LPSTR s) { try { USES_CONVERSION; CAtlFile oFile; CTime t = CTime::GetCurrentTime(); CAtlStringA sz; sz.Format("[%d-%d-%d %d:%d:%d] %s\r\n", t.GetYear(), t.GetMonth(), t.GetDay(), t.GetHour(), t.GetMinute(), t.GetSecond(), s); CComBSTR tem(sz); if (oFile.Create(_T("C:\\log\\test.txt"), GENERIC_WRITE, FILE_SHARE_READ, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL, NULL) == S_OK) { oFile.Seek(0, FILE_END); oFile.Write(tem, tem.ByteLength()); oFile.Close(); } } catch (...) { }
}
void writelog(CString cstring)
{
LPSTR lpwlog;
lpwlog = (LPSTR)(LPCTSTR)cstring;
writelogA(lpwlog);
}
STDMETHODIMP CTranslate::Lnl_InitCommunication()
{
CString cstring("Lnl_InitCommunication");
writelog(cstring);
return S_OK;
}
相关文章推荐
- Caffe源码中各种依赖库的作用及简单使用
- Caffe源码中各种依赖库的作用及简单使用
- ScrollView嵌套ListView起始位置不是顶部,ScrollView嵌套GridView起始位置不是顶部解决方法
- 《叩响C#之门》RichTextBox修改字体大小的研究
- 内核error: implicit declaration of function 'irq_to_gpio' 解决方法
- ios账号申请-从个人账号到企业账号升级之路
- 简单的存储过程
- 20150927js学习回顾
- 中秋快乐 亲们
- 04_链表
- 使用CSS达到阴阳八卦图等图形
- HDU - 5491 The Next 2015 ACM/ICPC Asia Regional Hefei Online
- HDU 5491 The Next 贪心
- 数据结构实验一____单链表操作
- kvm 虚拟化
- Reverse Words in a String
- 嵌入式Linux应用开发——Linux下的C编程基础
- 一个开始
- ACM题集以及各种总结大全!
- windows下使用lua教程(转)