如何在Win32应用程序中打印到调试输出窗口? [英] How do I print to the debug output window in a Win32 app?

查看:1799
本文介绍了如何在Win32应用程序中打印到调试输出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个win32项目,我已经加载到Visual Studio 2005.我想能够打印的东西到Visual Studio输出窗口,但我不能为我的生活解决了。我试过'printf'和'cout<<',但我的消息保持固执的不打印。

I've got a win32 project that I've loaded into Visual Studio 2005. I'd like to be able to print things to the Visual Studio output window, but I can't for the life of me work out how. I've tried 'printf' and 'cout <<' but my messages stay stubbornly unprinted.

有一些特殊的方式打印到Visual Studio输出窗口?

Is there some sort of special way to print to the Visual Studio output window?

推荐答案

您可以使用 OutputDebugString OutputDebugString 是一个宏,根据您的构建选项映射到 OutputDebugStringA(char const *) OutputDebugStringW(wchar_t const *)。在后一种情况下,您将必须为函数提供一个宽字符串。要创建宽字符文字,您可以使用 L 前缀:

You can use OutputDebugString. OutputDebugString is a macro that depending on your build options either maps to OutputDebugStringA(char const*) or OutputDebugStringW(wchar_t const*). In the later case you will have to supply a wide character string to the function. To create a wide character literal you can use the L prefix:

OutputDebugStringW(L"My output string.");

通常,您将使用宏版本和 _T 宏如下:

Normally you will use the macro version together with the _T macro like this:

OutputDebugString(_T("My output string."));

如果将项目配置为构建UNICODE,它将扩展为:

If you project is configured to build for UNICODE it will expand into:

OutputDebugStringW(L"My output string.");

如果您不是为UNICODE构建,它将扩展为:

If you are not building for UNICODE it will expand into:

OutputDebugStringA("My output string.");

这篇关于如何在Win32应用程序中打印到调试输出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆