Detecting Windows Shutdown
To detect Windows Shutdown, you must trap WM_EndSession message. These steps should be taken:
Declare a message handling procedure in your Form's Private section:
procedure WMEndSession(var Msg : TWMEndSession); message WM_ENDSESSION;
Add the procedure to the implementation section of your Unit:
procedure TForm1.WMEndSession(var Msg : TWMEndSession);
begin
if Msg.EndSession = TRUE then
ShowMessage('Windows is shutting down ' + #13 + 'at ' +
FormatDateTime('c', Now));
inherited;
end;

0 Comments:
Post a Comment
<< Home