开发者

Win32 Application Console Output?

When developing a Win32 Application (non-console application) in Visual Studio 2005, is there any way to get the same sort of output as you do from the console?

For instance, say I want to see log statements (such as I would with cout in a console application) to trace the path my program has taken in the code.

My first thought would be that this could be done through the Output tab selecting something from its "Show output from:" dropdown, when debugging but I don't know what API I need to do this...

Win32 Application Console Output?

For example say I had the following in my windows application and wanted to know when the following function enters and exits writing the result to the Visual Studio window above.

void someFunction(void)
{
   Win32APIConsoleLog("BEGIN: someFunction()");
   // ...
   Win32APIConsoleLog("END: someFunction()");
}

Is this possible? And if so, wh开发者_开发知识库at what libraries do I need to include and what function calls do I need to make to write out to the console window?


OutputDebugString.

I assume that you want to write to the debug console, since that's what your screenshot shows. OutputDebugString is a nop when no debugger is attached, but it allows you to log whatever you want to the debugger's output.

OutputDebugStringW(L"This will go to the output.\n");

// or

OutputDebugString("This will go to the output.\n");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜