【windows + DebugView】 -- 通过DebugView工具调试窗口程序

简述

对windows窗口程序调试时,如果没有或不能用log4cplus之类的日志打印的情况下,可以使用DebugView工具进行日志打印辅助调试

用到的工具

DebugView

用法

#include "debugapi.h"
/* API 定义:
WINBASEAPI VOID WINAPI OutputDebugStringA(_In_opt_ LPCSTR lpOutputString);
WINBASEAPI VOID WINAPI OutputDebugStringW(_In_opt_ LPCWSTR lpOutputString);
#ifdef UNICODE
#define OutputDebugString  OutputDebugStringW
#else
#define OutputDebugString  OutputDebugStringA
#endif // !UNICODE
*/

/* 简单打印示例*/
OutputDebugString("Hello World!");

uint32_t nums = 100;
/* 输出变量的示例1(UNICODE编码 + c++标准库的一种用法)*/
std::wstringstream stream;
stream << "The Nums: " << nums << std::endl;
OutputDebugString(stream.str().c_str()); 

/* 输出变量的示例2 (UNICODE编码 + C语言的一种用法) */
WCHAR szLog[128] = {0};
StringCbPrintf(szLog, 128, L"The Nums: %u
", nums);
OutputDebugString(szLog);
原文地址:https://www.cnblogs.com/mooooonlight/p/13789050.html