Win32编程之debugview调试(十一)
一、debugview本地调试
代码中通过OutputDebugString()函数打印印象:
for (int i = 0; i < 10; i++) {
OutputDebugString(TEXT("hello word"));
}
程序编程成功后,先打开DebugView

Include:默认是*,打印所有通过OutputDebugString()的信息,可以自定义为指定的信息去查找
Exclude:打印所有通过OutputDebugString()的信息,可以打印指定的exe程序的信息
DebugView打开后,双击可执行程序后:

二、debugview远程调试
服务端在命令行中执行dbgview64.exe /a,等待客户端链接

客户端打开DebugView,输入服务端的IP地址

连接成功后点击OK

然后在服务端双击Win32可执行程序:
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: 在此处放置代码。
OutputDebugString(TEXT("hello DebugView"));
// 初始化全局字符串
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_DEBUGDEMO, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// 执行应用程序初始化:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_DEBUGDEMO));
MSG msg;
// 主消息循环:
while (GetMessage(&msg, nullptr, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
编译成功后双击可执行文件,每点击一次便会打印一次信息:


浙公网安备 33010602011771号