esk
asked on
Trap ShutDown Event both on NT and Win9x
I want to trap event when my os is shutingdown both for win9x and nt
Esk
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Esk, how about the other question? I'm still waiting for your response...
You do not need to seet msg to 1 or 0.
If user click, Start-Shutdown, then
WM_QUERYENDSESSION will be invoked.
So, just put your routines to the procedure WMQueryEndSession (var Message: TMessage); message WM_QUERYENDSESSION ;
Hope it will help,
Daniel
If user click, Start-Shutdown, then
WM_QUERYENDSESSION will be invoked.
So, just put your routines to the procedure WMQueryEndSession (var Message: TMessage); message WM_QUERYENDSESSION ;
Hope it will help,
Daniel
ASKER
does this work on my nt machine?
ASKER
Epsylon, how about NT?
Wow, I did not propose the answer. I only picked up your life sign here :o)
ASKER
Alright , thanks but do you own asnwer for my question, you get 100 extra points + A
Esk
Esk
ASKER
Epsylon, i trust on you
I think this should be it:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMQueryEndSession (var Message: TMessage); message WM_QUERYENDSESSION ;
procedure WMEndSession (var Message: TMessage); message WM_ENDSESSION ;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TForm1 }
procedure TForm1.WMQueryEndSession(v ar Message: TMessage);
begin
if MessageDlg('WM_QUERYENDSES SION', mtConfirmation, mbOKCancel, 0) = mrOk then
Message.Result := Integer(true)
else
Message.Result := Integer(false);
end;
procedure TForm1.WMEndSession(var Message: TMessage);
begin
if BOOL(Message.WParam) = true then
Close;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMQueryEndSession (var Message: TMessage); message WM_QUERYENDSESSION ;
procedure WMEndSession (var Message: TMessage); message WM_ENDSESSION ;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TForm1 }
procedure TForm1.WMQueryEndSession(v
begin
if MessageDlg('WM_QUERYENDSES
Message.Result := Integer(true)
else
Message.Result := Integer(false);
end;
procedure TForm1.WMEndSession(var Message: TMessage);
begin
if BOOL(Message.WParam) = true then
Close;
end;
end.
ASKER
won't work on my NT
ASKER
This work!!! sorry
ASKER
daniel_c, i gave you the points.
i was trying to give Epsylon the points, his aswer was right
Esk
i was trying to give Epsylon the points, his aswer was right
Esk
Hmmm......
ASKER
Is no way to take the points back?
ASKER
Esk