Board index » delphi » Shutting down software using a UPS

Shutting down software using a UPS

This question is both Delphi based and a bit off topic:

I have an office where all my computers are run via an inverter. This
is because it is cheaper for me than buying a huge UPS. I can also
charge the batteries etc using solar. I have built the charging system
and the battery supply system and it monitors each indevidual battery
etc. I can get that info into a computer and delphi etc.

Ok my question is this:

If the system says the batteries are about to fail how do you tell
windows to shutdown with no questions asked?

What I mean is with certain software packages, if you tell windows to
shutdown it asks do you want to save etc etc etc. Ok I understand that
you cannot be there to answer that question and well thats the way it
goes. But due to that software doing that, what happens to the rest?
Will they all shutdown in the background?

Regards, Peter

 

Re:Shutting down software using a UPS


Have a look at ExitWindowsEx

EWX_FORCE       looks pretty drastic

On 14 Nov 2002 03:39:37 -0800, goo...@sale-net.com.au (Peter) wrote:

Quote
>This question is both Delphi based and a bit off topic:

>I have an office where all my computers are run via an inverter. This
>is because it is cheaper for me than buying a huge UPS. I can also
>charge the batteries etc using solar. I have built the charging system
>and the battery supply system and it monitors each indevidual battery
>etc. I can get that info into a computer and delphi etc.

>Ok my question is this:

>If the system says the batteries are about to fail how do you tell
>windows to shutdown with no questions asked?

>What I mean is with certain software packages, if you tell windows to
>shutdown it asks do you want to save etc etc etc. Ok I understand that
>you cannot be there to answer that question and well thats the way it
>goes. But due to that software doing that, what happens to the rest?
>Will they all shutdown in the background?

>Regards, Peter

Re:Shutting down software using a UPS


On 14 Nov 2002 03:39:37 -0800, goo...@sale-net.com.au (Peter) wrote:

Quote
>This question is both Delphi based and a bit off topic:

>I have an office where all my computers are run via an inverter. This
>is because it is cheaper for me than buying a huge UPS. I can also
>charge the batteries etc using solar. I have built the charging system
>and the battery supply system and it monitors each indevidual battery
>etc. I can get that info into a computer and delphi etc.

Nice one.

Quote
>If the system says the batteries are about to fail how do you tell
>windows to shutdown with no questions asked?

ExitWindowEx(EWX_FORCE or EWX_POWEROFF, 0);

See also the thread from last week entitled "Shut Down?" which
discussed the user priviledges that may be required.

--
jc

Re:Shutting down software using a UPS


Quote
Peter <goo...@sale-net.com.au> wrote in message

news:6a3f6a71.0211140339.39dfed15@posting.google.com...

Quote
> This question is both Delphi based and a bit off topic:

> If the system says the batteries are about to fail how do you tell
> windows to shutdown with no questions asked?

ExitWindowsEx()

Quote
> What I mean is with certain software packages, if you tell windows to
> shutdown it asks do you want to save etc etc etc. Ok I understand that
> you cannot be there to answer that question and well thats the way it
> goes. But due to that software doing that, what happens to the rest?
> Will they all shutdown in the background?

Each application in turn is sent a WM_QUERYENDSESSION message which must
respond within the timeout of SendMessageTimeout(), normally some 10 seconds
or so, by indicating it is OK to close down. W98 will stop querying when it
encounters an application that does not respond in the affirmative. If all
applications OK this message,  then they are sent the WM_ENDSESSION message
which will inidicate whether the application is to be immediately
terminated. Thus for W98, if one application is ill-mannered, it is quite
possible for other applications to be left open, and when the power does go
down, you'll lose what's in the buffers. A simple test is to try closing
windows in the usual manner with your typical applications open. If
closedown goes without a hitch, then you should be OK.

Dave

Other Threads