System Delphi

Title: detect a Windows Shutdown?
{
To detect a Windows Shutdown, you must trap the
WM_EndSession message.
Declare a message handling procedure in your Form's Private section.
Um herauszufinden, ob Windows heruntergefahren wird, muss
die WM_EndSession abgefangen werden.
}
type
TForm1 = class(TForm)
private
procedure WMEndSession(var Msg: TWMEndSession); message WM_ENDSESSION;
public
end;
implementation
{$R *.DFM}
procedure TForm1.WMEndSession(var Msg: TWMEndSession);
begin
if Msg.EndSession = True then
ShowMessage('Windows is shutting down!');
inherited;
end;