通过std::string添加打印信息
std::string& std_string_format(std::string& _str, const char* _Format, ...) {
std::string tmp;
va_list marker = NULL;
va_start(marker, _Format);
size_t num_of_chars = _vscprintf(_Format, marker);
if (num_of_chars > tmp.capacity()) {
tmp.resize(num_of_chars + 1);
}
vsprintf_s((char*)tmp.data(), tmp.capacity(), _Format, marker);
va_end(marker);
_str = tmp.c_str();
return _str;
}
void PintMsg(std::string strInfo)
{
std::string strTime;
SYSTEMTIME lpsystime;
GetLocalTime(&lpsystime);
std_string_format(strTime, "%d-%d-%d %d:%d:%d", lpsystime.wYear, lpsystime.wMonth, lpsystime.wDay, lpsystime.wHour,
lpsystime.wMinute, lpsystime.wSecond, lpsystime.wMilliseconds);
std::string strTemp = strTime + " " + strInfo;
OutputDebugStringA(strTemp.c_str());
}
// 获取本地时间精确到毫秒
CString strTime;
SYSTEMTIME lpsystime;
GetLocalTime(&lpsystime);
strTime.Format(L"%d%d%d%d%d%d%d.bmp", lpsystime.wYear, lpsystime.wMonth, lpsystime.wDay, lpsystime.wHour,
lpsystime.wMinute, lpsystime.wSecond, lpsystime.wMilliseconds);