#pragma warning(disable : 4996)
#include "stdafx.h"
#include <windows.h>
#include <ctime>
#include <fstream>
#include <string>
#define _CRT_SECURE_NO_WARNINGS
void WriteLog(char *lpBuffer)
{
char _szFileName[100];
GetCurrentDirectory(256,_szFileName);
strcat(_szFileName,"\\wLog.txt");
std::string path=_szFileName;
time_t t = time(0);
char tmp[64];
strftime(tmp, sizeof(tmp), "[%Y.%m.%d %X] ", localtime(&t));
std::string loginfo=tmp;
loginfo.append(lpBuffer);
std::ofstream ofs;
ofs.open(path.c_str(), std::ofstream::app);
ofs.write(loginfo.c_str(), loginfo.size());
ofs <<'\n';
ofs.close();
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WriteLog("测试软件");
return 0;
}