What happens when you close a c++ console application(关闭 C++ 控制台应用程序时会发生什么)
问题描述
我想这个问题说明了一切,但是,如果有人关闭了 C++ 控制台应用程序会发生什么?如,单击顶角的x".它会立即关闭吗?它会抛出某种异常吗?这是未定义的行为吗?
I guess the question says it all, but, what happens if someone closes a c++ console app? As in, clicks the "x" in the top corner. Does it instantly close? Does it throw some sort of exception? Is it undefined behavior?
推荐答案
关闭带有x"在顶角的 c++ 控制台应用程序会抛出一个 CTRL_CLOSE_EVENT
,如果您设置,您可以捕获和处理使用 SetConsoleCtrlHandler 函数的控制处理程序.在那里,您可以覆盖关闭功能并执行您想做的任何事情,然后仍然可以选择执行默认行为.
Closing a c++ console app with the "x" in the top corner throws an CTRL_CLOSE_EVENT
which you could catch and process if you set a control handler using the SetConsoleCtrlHandler function. In there you could override the close functionality and perform whatever you wished to do, and then optionally still perform the default behavior.
这篇关于关闭 C++ 控制台应用程序时会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:关闭 C++ 控制台应用程序时会发生什么


- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 静态初始化顺序失败 2022-01-01
- C++ 协变模板 2021-01-01
- 从python回调到c++的选项 2022-11-16
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 近似搜索的工作原理 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01