Detecting power loss

Posted on 2004-11-19
Last Modified: 2007-12-19
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?
Question by:monthathip
    1 Comment
    LVL 4

    Accepted Solution


    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.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now