#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;
}