TRACE() OutputDebugString()
- 在 Debug 模式下,TRACE() 和OutputDebugString() 两者都输出在下面的窗口 “调试 (debug)” 窗口;

- 在 Release 模式下,TRACE 不起作用
OutputDebugString 可以通过 dgbview.exe 查看,但它不支持 格式化字符串
自定义输出函数
ASCII版本:void DbgOutput(const char *szFormat, ...) {#ifdef _DEBUGchar szbufFormat[0x1000];char szBufFormat_Game[0x1010] = "CPALyth:";va_list argList;va_start(argList, szFormat); //参数列表初始化vsprintf_s(szbufFormat, szFormat, argList);strcat_s(szBufFormat_Game, szbufFormat);OutputDebugStringA(szBufFormat_Game);va_end(argList);#endif}Unicode版本:void DbgOutputW(const TCHAR *szFormat, ...) {#ifdef _DEBUGTCHAR szbufFormat[0x1000];TCHAR szBufFormat_Game[0x1010] = L"CPALyth:";va_list argList;va_start(argList, szFormat); //参数列表初始化vswprintf_s(szbufFormat, szFormat, argList);wcscat(szBufFormat_Game, szbufFormat);OutputDebugString(szBufFormat_Game);va_end(argList);#endif}
