让 win32 程序也可以从 console 输出信息
今天同事在调试一个 win32 程序的时候,希望从 console 输出一些调试信息。他威胁说,否则,就要动用邪恶的 MessageBox 了。
我们以前的库倒是提供了一个 console 模块,可以从 win32 程序中创建出一个 console 。然后把标准输入输出定向到上面。这并不麻烦,就算不用翻出以前的代码重用一下,查下 MSDN 自己写上几句也可以解决。
今天突然想到,其实还有一个更 kiss 的解决方法。那就是直接开一个 console ,再在上面执行需要调试的程序。只不过直接运行是不会得到任何输出的,需要多做一步的是使用管道操作。
例如,需要调试的程序是 test ,那么只需要写 test | more 就可以把 test 的标准输出导向 more ,那么 more 就能捕获所有 test 的标准输出并显示在控制台上了。
Comments
Posted by: Peter | (13) August 18, 2008 03:02 PM
Posted by: gobr | (12) August 26, 2007 07:17 PM
Posted by: hppychui | (11) January 29, 2007 10:37 AM
Posted by: chen3feng | (10) January 19, 2007 12:55 AM
Posted by: dreamsun | (9) January 17, 2007 04:46 PM
Posted by: sunway | (8) January 17, 2007 01:13 PM
Posted by: analyst | (7) January 16, 2007 11:53 PM
Posted by: Cloud | (6) January 16, 2007 10:29 PM
Posted by: ai | (5) January 16, 2007 10:24 PM
Posted by: analyst | (4) January 16, 2007 10:18 PM
Posted by: Cloud | (3) January 16, 2007 07:17 PM
Posted by: sunway | (2) January 16, 2007 05:31 PM
Posted by: analyst | (1) January 16, 2007 05:15 PM