Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Prevent or Abort Windows Shutdown.

Posted on 1999-07-05
9
Medium Priority
?
397 Views
Last Modified: 2010-04-06
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
Comment
Question by:MikeADST
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1386523
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1386524
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
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1386525
Forget the drinking Viktor, you need to get off the drugs!

Cheers,

Raymond.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Accepted Solution

by:
rwilson032697 earned 300 total points
ID: 1386526
And with the ringing endorsement from Viktor, I'll make it an answer...

Cheers,

Raymond.

0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1386527
i suggest 2 drink even more - helped me 2... ;-)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1386528
thatz what i wanna hear.... gimme 5 BD ;) i meant dollars :)
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1386529
hi5, cheers!
0
 
LVL 1

Author Comment

by:MikeADST
ID: 1386530
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
 
LVL 1

Author Comment

by:MikeADST
ID: 1386531
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question