如何在GUI应用程序中写入控制台 [英] How to write to the console in a GUI application
问题描述
背景:我们开发win32应用程序,并在Windows上使用 Thompson Toolkit为我们提供了一个类unix的外壳,我们将其用作命令行。
Background: We develop win32 applications, and use the "Thompson Toolkit" on windows to give us a unix-like shell that we use as our command-line.
我们有一个要写入控制台的GUI程序(带有WinMain和消息循环),但是即使从控制台启动该程序,printf等也不起作用。我们如何从GUI程序写入控制台?我们需要在此处打印文本,以便自动构建系统可以显示错误消息等。
We have a GUI program (with a WinMain and message loop) that we want to write to the console, but printf and so on don't work, even when we launch the program from the console. How can we write to the console from a GUI program? We need to print text there so that an automated build system can display error messages and so on.
谢谢。
推荐答案
简而言之,您需要附加一个控制台。有关详细信息和准备使用的代码,请参见 http://www.codeproject.com/KB/ dialog / ConsoleAdapter.aspx 。
In short, you need to attach a console. For details and ready to use code, see http://www.codeproject.com/KB/dialog/ConsoleAdapter.aspx.
这篇关于如何在GUI应用程序中写入控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!