Example Program Drafts

Showing results for 
Search instead for 
Did you mean: 

.NET PowerModeChanged Notifier - Monitor your UPS or Laptop Power from LabVIEW


Listens for UPS state changes via .NET and generates a LV Notifier containing the UPS state.


this VI demonstrates how to get the power source status of your computer. It constantly polls the operating system for the power source information. The power source values are an estimate provided by the battery driver. This VI was developed for use in laptop computers, however, it also operates correctly in UPS units with a Windows battery driver. The return values of the call to the Windows DLL are formatted and presented in the front panel.

Steps to Implement or Execute Code

  1. Run the dotNET System Power VI.



.NET 2.0

LabVIEW Development System 8.0 or later

Windows 98 or later



Additional Images or Video


Registers for the Microsoft.Win32.SystemEvents.PowerModeChanged Event. The included Callback VI performs a "GetSystemPowerStatus" Win32 API call and sends the returned structure as a LV Notification.

I've modified the original SystemPower VI from here and included it as an example of how to use the notifier.

17 May 2007 - Note: There are problems/issues in using this with APCC software. See this NI Forum thread. http://forums.ni.com/ni/board/message?board.id=170&message.id=212642#M212642.

Change control:

Added Link to forum thread discussing use and limitations of this function...

by Phillip Brooks

VI Snippet


**This document has been updated to meet the current required format for the NI Code Exchange. For more details visit this discussion thread**

  • Find more articles tagged with:
Member subsolanus

This thing worked great right out of the box. LV 2009 (32), Windows 7 (64), APC Smart UPS RT2000 over USB w/ native MS UPS driver. Thanks!!!! Saved me a major PIA.

Dave W

Member Marls

This VI, or to be more specific the PowerModeChanged.vi caused a memory leak on my system.

Member Zilo

Hi, We try to use this example on a desktop PC with APC BX700-GR ups, and PowerChute Personal Edition 3,0,2 sw.

But unfortunately does not work. The program seen "No battery" and "AC Power" all the time, does not matter if UPS working or not.

We checked it on a laptop with internal battery, there is works correcty.

Does anybody have ideas how we could monitoring the APC PX700 ups?

Thanks in advance.

Zoltan Vanyi

Member REDV12

Hi everybody,


you should remove the absolute path to kernel32.dll in the Call Library Function Node, I've recently had issues with a 32bit application on a 64bit Windows, because the VI loaded ...\System32\kernel32.dll, while all the other processes were already using ...\SysWOW64\kernel32.dll.


Hope my advice helps some people to prevent crashing or hanging applications Smiley Happy