当关闭c ++控制台应用程序时会发生什么 [英] What happens when you close a c++ console application

查看:155
本文介绍了当关闭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?

推荐答案

关闭一个c ++控制台应用程序,顶部的x会抛出 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 ++控制台应用程序时会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆