如何在Metro应用程序中写入控制台/登录VC ++?

时间:2012-07-04 05:07:56

标签: visual-c++ windows-8 microsoft-metro

我正在研究vc ++应用程序,在这个应用程序中如何写入console / log?

c#---- system.diagnostics.debug.writeline(“你好”); 相近 Vc ++ ----?

2 个答案:

答案 0 :(得分:4)

metro风格的应用程序不能有控制台。您可以在C ++ / CXX应用程序中使用OutputDebugString()在Visual Studio输出窗口中显示调试文本,就像System.Diagnostics.Debug.Write在托管应用程序中一样。没有很多已批准的winapi函数,但OutputDebugString()是可以的。启动MSDN页面is here

答案 1 :(得分:0)

如果您正在创建GUI应用程序,则可以自己启用控制台。

AllocConsole();
freopen("CONOUT$", "w+t", stdout);

然后,您可以简单地将std :: cout或printf作为诊断消息。