#include <io.h>
#include <fcntl.h>
#include <io.h>
#include <fcntl.h>
void OpenConsole()
{
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
int hCrt = _open_osfhandle((long)handle,_O_TEXT);
FILE * hf = _fdopen( hCrt, "w" );
*stdout = *hf;
}
然后在应用app 的InitInstance()里调用一下OpenConsole();即可
本文介绍了一种在C++应用程序中打开控制台的方法。通过使用特定的Windows API函数,可以实现在程序运行时动态创建并显示控制台窗口。这种方法对于需要在运行时显示额外调试信息的应用特别有用。
3274

被折叠的 条评论
为什么被折叠?



