DetectAC         Detect AC power status on Windows

Why detect AC power status?

Laptops are becoming more and more popular. One advantage is that they can be used without power supply with the help of a battery. Unfortunately when a laptop is not connected to a power supply the performace will be degraded (sometimes considerably). It can be useful to detect this and show a message to the user explaining why the application might not perform very well.
This code snippet shows how the "detecting part" can be done using the Windows API.

Code snippet

       SYSTEM_POWER_STATUS _status;
       if(_status.ACLineStatus == 0)
           return false;
       } else {
           return true;

Dont forget to include windows headers also for this to work:

#include "windows.h"

--Borundin 20:26, 4 July 2008 (BST)