• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

Prevent or Abort Windows Shutdown.

Is there a way to abort a Windows 95+ shutdown?

I tried the form's OnCloseQuery event and set the CanClose to false. The program reactivated, but Windows shut down anyway.
Basically, when Windows shuts down, I would like to have a Dialog pop-up and ask "Do you wish to Clock Out?". If yes, I would like to abort the Windows shutdown and allow the user to use the program. Then, Windows can be shutdown (again, if necessary).

I am writing an application for use in both Windows 95 and 3.1 (Delphi 1). If the answer applies only to Delphi 2 or above, the information could still be useful.

Thanks,

MikeADST

0
MikeADST
Asked:
MikeADST
  • 3
  • 2
  • 2
  • +1
1 Solution
 
rwilson032697Commented:
if you want to detect when windows 95/98 shutdown and your app is still running you can do this:

in your forms private section:

procedure WMQueryEndSession(var M:TWMQueryEndSession); message
WM_QueryEndSession;

and then somewhere after {$R *.DFM} put this:

procedure TForm1.WMQueryEndSession(var M:TWMQueryEndSession);
  begin
    Showmessage('windows is shutting down');{or do  whatever}
  Inherited
end;

To stop the shutdown I think you set M.result to 1 (or 0, one of the 2...)

Cheers,

Raymond.

0
 
viktornetCommented:
procedure WMQueryEndSession(var M:TWMQueryEndSession); message
      WM_QueryEndSession;

      and then somewhere after implementation put this:

      procedure TForm1.WMQueryEndSession(var M:TWMQueryEndSession);
        begin
          Showmessage('windows is going to rape you.... evacuate!!');{or do  whatever}
          M.Result := 1;
      end;


No one knows ..-=ViKtOr=-..
0
 
rwilson032697Commented:
Forget the drinking Viktor, you need to get off the drugs!

Cheers,

Raymond.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
rwilson032697Commented:
And with the ringing endorsement from Viktor, I'll make it an answer...

Cheers,

Raymond.

0
 
BlackDeathCommented:
i suggest 2 drink even more - helped me 2... ;-)
0
 
viktornetCommented:
thatz what i wanna hear.... gimme 5 BD ;) i meant dollars :)
0
 
BlackDeathCommented:
hi5, cheers!
0
 
MikeADSTAuthor Commented:
Thanks for the answer.
Incidently, I found that the also worked as long as the form is visible. (It didn't work the 1rst time I tried because the form was not visible).

Thanks too to ViKtOr for your comment.

Mike

0
 
MikeADSTAuthor Commented:
Sorry, the above comment should say:

Incidently, I found that the OnCloseQuery event also worked as long as the form is visible. (It didn't work the 1rst time I tried because the form was not visible).

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now