Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I intercept the Windows Shutdown Command ?

70 views
Skip to first unread message

Gary Freestone

unread,
Sep 13, 1999, 3:00:00 AM9/13/99
to
I am trying to write a Delphi program that runs minimized and "wakes up"
only when windows is told to shutdown. At this point the user will have
the option to continue the shutdown or perform a task first then
shutdown.

The problem is a can't figure out how to intercept the windows shutdown.
Any help most appreciated. I
am using D2.

Gary Freestone


Bruce Roberts

unread,
Sep 13, 1999, 3:00:00 AM9/13/99
to
Can't you just override the WM_CLOSE message? Windows will close your
program down before it shuts itself down.

Gary Freestone <ga...@au1.ibm.com.REMOVETOREPLY> wrote in message
news:37DC5D0F...@au1.ibm.com.REMOVETOREPLY...

Jan Goyvaerts

unread,
Sep 13, 1999, 3:00:00 AM9/13/99
to Gary Freestone
Gary Freestone wrote:
>
> The problem is a can't figure out how to intercept the windows shutdown.
> Any help most appreciated. I am using D2.

Add an event handler for the WM_ENDSESSION message to your form.

Regards,
Jan.

--
http://www.jgsoft.com/helpscr.shtml
In the April 1999 issue, Delphi Informant readers selected HelpScribble
as the "Best Help Authoring Package", leaving well-known commercial
packages as RoboHelp and ForeHelp (which were also nominated) behind it.

Gary Freestone

unread,
Sep 14, 1999, 3:00:00 AM9/14/99
to
Hi,

Thanks for your help, you pointed me in the right direction. Just in case
people are interested.....

The following example works:

Where Form1 is the main form and the event is OnCloseQuery.

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if MessageDlg('Close the form and Shut down Windows ?', mtConfirmation,
[mbYes, mbNo], 0) = mrNo then CanClose := False;
end;

Once again Thanks for your help.

Gary Freestone

Radikal

unread,
Sep 14, 1999, 3:00:00 AM9/14/99
to
On Mon, 13 Sep 1999 03:35:13 GMT, "Bruce Roberts"
<no.junk.p...@attcanada.net> wrote:

>Can't you just override the WM_CLOSE message? Windows will close your
>program down before it shuts itself down.
>

Is better use the WM_QUERYENSESSION message

An example of this in Trucomania, tip
[31] Avoid that the user closes Windows
www.q3.nu/trucomania/truco.cgi?31&ing

Un Saludo:
Radikal
www.q3.nu/trucomania

0 new messages