关闭挂钩c ++ [英] Shutdown Hook c++

查看:152
本文介绍了关闭挂钩c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在终止时运行代码,无论什么类型的终止(异常,正常,未捕获异常等)?
我知道它实际上可能在Java,但是它甚至可能在C + +?假设有一个windows环境。

is there some way to run code on termination, no matter what kind termination (abnormal,normal,uncaught exception etc.)? I know its actually possible in Java, but is it even possible in C++? Im assuming a windows environment.

推荐答案

否 - 如果有人调用 TerminateProcess ,您的进程将被销毁,而不会进一步adieu,(特别是)没有任何机会,在关闭过程中运行任何更多的代码。

No -- if somebody invokes TerminateProcess, your process will be destroyed without further adieu, and (in particular) without any chance to run any more code in the process of shutting down.

这篇关于关闭挂钩c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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