detect a logoff

Giganews Newsgroups
Subject: detect a logoff
Posted by:  meik (m7061025…@msn.com)
Date: 12 Sep 2006

I'm trying to detect when a user logsoff windows.  I have the following code, but it is not quite right.  Could someone help me figure out where it falls down.
Thanks

private
  procedure WMQueryEndSession(var Msg : TWMQueryEndSession); message WM_QueryEndSession;

procedure TMainForm.WMQueryEndSession(var Msg : TWMQueryEndSession);
begin
If (msg.result  = ENDSESSION_LOGOFF) Then  MainForm.Close;
Inherited;
End;

Replies