Board index » delphi » Find out type of shutdown (shutdown, restart etc)

Find out type of shutdown (shutdown, restart etc)

Is it possible to find out if the system is shutting down, restarting or the
user is logging off?

My app copies some files in the CloseQuery event and sets CanClose to true
at the end. The problem is that before the copying has finished Windows XP
thinks it is taking too long and shows a dialog which terminates my app
after a few seconds. I've worked around this by setting CanClose to false,
start the copying after that and finally shut down the system in code. It
would be nice though if i could perform the same action (shutdown, restart,
log off) instead of always shutting down.

TIA
  Ronald

 

Re:Find out type of shutdown (shutdown, restart etc)


On Thu, 19 Dec 2002 23:05:56 +0100, "Ronald" <nom...@nomail.com>
wrote:

Quote
>Is it possible to find out if the system is shutting down, restarting or the
>user is logging off?

>My app copies some files in the CloseQuery event and sets CanClose to true
>at the end. The problem is that before the copying has finished Windows XP
>thinks it is taking too long and shows a dialog which terminates my app
>after a few seconds. I've worked around this by setting CanClose to false,
>start the copying after that and finally shut down the system in code. It
>would be nice though if i could perform the same action (shutdown, restart,
>log off) instead of always shutting down.

Handle the WM_QUERYENDSESSION message, and return FALSE to prevent the
shutdown. Examine the lParam of the message to determine the type of
shutdown.

--
jc

Other Threads