简体   繁体   English

C ++ WinAPI-Windows关闭终止进程之前进行清理?

[英]C++ WinAPI - cleanup before windows shutdown terminates the process?

Typically, you can capture the WM_CLOSE event to do cleanup tasks before the application terminates, when working with GUI windows. 通常,使用GUI窗口时,可以捕获WM_CLOSE事件以在应用程序终止之前执行清理任务。

However, if my application just runs in the background and the process is terminated only when windows is shut down - is there any way to capture this event and perform some cleanup before the process is terminated? 但是,如果我的应用程序仅在后台运行,并且仅在关闭Windows时进程终止,那么是否有任何方法可以捕获此事件并在进程终止之前执行一些清除操作?

I know that it's not possible to intervene with the task managers process closing. 我知道不可能干预任务管理器的流程结束。 But with the shutdown I just noticed there is a shutdown and a shutdown /F command. 但是,在关机时,我只是注意到有一个shutdown和一个shutdown /F命令。

创建一个仅消息窗口 ,并处理WM_QUERYENDSESSION和/或WM_ENDSESSION消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM