Example Code

Check if PC is on Battery Power with GetSystemPowerStatus in Kernel32.DLL

Code and Documents

Attachment

Overview

This example demonstrates how to programmatically check if your PC is on AC or battery power by calling the GetSystemPowerStatus function from the Windows' kernel32.dll.

Description

Calls GetSystemPowerStatus and gets the ACLineStatus output.  If this value is 1, the AC Power? indicator is true; otherwise it is false.


Check if Computer is on AC Power.PNG

Steps to Implement or Execute Code

  1. Run VI

Requirements

Software

LabVIEW 2012 or later

Hardware

PC

Additional Images or Video



Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors