Detect closing of application from windows
-
I need to save some settings to the registry when the user closes my application. For this purpose i use the WM_DESTROY message and it works fine. Now i noticed that the application doesn't receive this message when a user terminates Windows without closing my application before. How can I detect that the application closes in such a case. MS
-
I need to save some settings to the registry when the user closes my application. For this purpose i use the WM_DESTROY message and it works fine. Now i noticed that the application doesn't receive this message when a user terminates Windows without closing my application before. How can I detect that the application closes in such a case. MS
There are several other ways that Windows destroys it windows. The alternate shutdown is in the WM_COMMAND message when the user clicks on the small *X* or closes from the toolbar. The paramater sent to WM_COMMAND is the IDCANCEL and IDOK default macros. Simply intercept these messages in addition to WM_DESTROY and call the same exit procedures that you have setup for WM_DESTROY. Both IDOK and IDCANCEL are always Windows specific so if you do not program these in then they will call for the Window to destroy without saving any work including freeing memory. IDCANCEL and IDOK, though, is pretty generic so you might want to consider calling the DestroyWindow( HWND ) yourself in addition.
-
I need to save some settings to the registry when the user closes my application. For this purpose i use the WM_DESTROY message and it works fine. Now i noticed that the application doesn't receive this message when a user terminates Windows without closing my application before. How can I detect that the application closes in such a case. MS
Check out the
WM_QUERYENDSESSION
andWM_ENDSESSION
messages.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
Check out the
WM_QUERYENDSESSION
andWM_ENDSESSION
messages.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
Thank you David, WM_ENDSESSION did the trick. MS