Detecting power loss

I have a vb application that will be left running 24/7.
The PC will be fitted with a UPS so I need to detect when the mains power fails and the ups kicks in so that I can safely close the application.
I have tried the GetSystemPowerStatus API but this only seems to work with laptops ie, detects when the laptop goes from mains to battery.

Anyone know how I can detect through vb when the ups kicks in?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


I believe the UPS has been connected to the computer through a port.  You should look at the documentation that comes with the UPS to know how to retrieve status of the UPS.  Such UPS may come with its own software, and the software may be configured to take some actions (send emails, open an application, run a script, etc.) based on its status.  If there is no documentation on port communication, you may have it trigger a script which does something.

hope this helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.