Console.cpp
上传用户:wxchtg88
上传日期:2022-05-17
资源大小:3340k
文件大小:1k
- #include "StdAfx.h"
- #include "Console.h"
- CConsole* CConsole::m_selfInstance = NULL;
- CConsole::CConsole(void)
- {
- BOOL bRtn = AllocConsole();
- m_hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
- }
- CConsole::~CConsole(void)
- {
- FreeConsole();
- }
- void CConsole::Print(LPCSTR lpszMsg, ...)
- {
- CHAR szBuffer [4096];
- CHAR szBuffer2[4096];
- va_list argList;
- va_start(argList, lpszMsg);
- vsprintf(szBuffer, lpszMsg, argList);
- va_end (argList);
- SYSTEMTIME st;
- GetLocalTime(&st);
- sprintf(szBuffer2, "[%04d-%02d-%02d %02d:%02d:%02d %d] %s",
- st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, szBuffer);
- DWORD dwWritten;
- WriteFile(m_hOutput, szBuffer2, strlen(szBuffer2), &dwWritten, NULL);
- }