用处:release版本中打印信息:
用法:在工程中加入类DebugShow.h:
包含到调用部分#include<DebugShow.h>
类DebugShow就一个函数:
BOOL DebugTrace(TCHAR * lpszFormat,...) { static HWND hwnd = ::FindWindow(NULL, _T("DbgView")); if(!IsWindow(hwnd)) hwnd = ::FindWindow(NULL, _T("DbgView")); if(hwnd) { static TCHAR szMsg[512]; va_list argList; va_start(argList, lpszFormat); try { _vstprintf(szMsg,lpszFormat, argList); } catch(...) { _tcscpy(szMsg ,_T("DebugHelper:Invalid string format!")); } va_end(argList); DWORD dwId = GetCurrentProcessId(); ::SendMessage(hwnd,WM_SETTEXT,dwId,(LPARAM)(LPCTSTR)szMsg); } return TRUE; }
直接调用也可,适用于unicode和多字节环境
=====>DbgView.exe和调用类下载