Need close message on shutdown

I have an MFC application which continually runs in the
background.  The only time the application closes is when
the machine is shutdown.  The application needs to be able to detect when the machine is shutdown so that it can close cleanly.

When the machine is shutdown, the CMainFrame::OnClose()
function is not being called.  How can we detect that the
machine is being shutdown?
Who is Participating?
Tommy HuiConnect With a Mentor EngineerCommented:
You can catch WM_QUERYENDSESSION to detect when someone requests the Windows session to end.
Tommy HuiEngineerCommented:
To detect when the session is shutting down, catch WM_ENDSESSION.
kaplan1Author Commented:
All Courses

From novice to tech pro — start learning today.