netik
netik

Reputation: 1826

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.

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?

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.

Upvotes: 1

Views: 388

Answers (1)

IInspectable
IInspectable

Reputation: 51345

Create a message-only window, and handle the WM_QUERYENDSESSION and/or WM_ENDSESSION messages.

Upvotes: 6

Related Questions