Win32 programming hiding console window(Win32 编程隐藏控制台窗口)
问题描述
我正在学习 C++,并制作了一个新程序.我删除了一些代码,现在我的控制台窗口没有隐藏.有没有办法让它在启动时隐藏而不让他们看到?
I'm learning C++ and I made a new program. I deleted some of my code and now my console window is not hidden. Is there a way to make it hide on startup without them seeing it?
推荐答案
如果你正在编写一个控制台程序,并且你想断开你的程序与它开始的控制台的连接,那么调用 FreeConsole.最终,您可能不会对该函数的实际功能感到满意,但这就是您所问问题的字面答案.
If you're writing a console program and you want to disconnect your program from the console it started with, then call FreeConsole. Ultimately, you probably won't be satisfied with what that function really does, but that's the literal answer to the question you asked.
如果您编写的程序一开始就不想拥有控制台,那么请配置您的项目,使其不是控制台程序.控制台"是 EXE 文件的一个属性.操作系统读取该设置并决定是否在您的任何代码运行之前为您的程序分配一个控制台,因此您无法在程序中控制它.有时,非控制台程序称为GUI 程序",因此您可能会在开发环境的配置选项中寻找控制台"和GUI"之间的选择.不过,将其设置为 GUI 并不要求您有任何用户界面.该设置仅控制您的程序是否以控制台启动.
If you're writing a program that you never want to have a console in the first place, then configure your project so that it is not a console program. "Consoleness" is a property of the EXE file. The OS reads that setting and decides whether to allocate a console for your program before any of your code ever runs, so you can't control it within the program. Sometimes a non-console program is called a "GUI program," so you might look for a choice between "console" and "GUI" in the configuration options of your development environment. Setting it to GUI doesn't require that you have any user interface at all, though. The setting merely controls whether your program starts with a console.
如果您正在尝试编写一个有时可以有控制台而有时没有的程序,那么请参阅之前的问题,一个可执行文件可以既是控制台应用程序又是 GUI 应用程序吗?
If you're trying to write a program that can sometimes have a console and sometimes not, then please see an earlier question, Can one executable be both a console and GUI app?
这篇关于Win32 编程隐藏控制台窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Win32 编程隐藏控制台窗口
基础教程推荐
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 我有静态或动态 boost 库吗? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
