Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
System Services
Power Management
 GetSystemPowerStatus function
GetSystemPowerStatus function

Applies to: desktop apps only

Retrieves the power status of the system. The status indicates whether the system is running on AC or DC power, whether the battery is currently charging, and how much battery life remains.

Syntax

BOOL WINAPI GetSystemPowerStatus(
  __out  LPSYSTEM_POWER_STATUS lpSystemPowerStatus
);

Parameters

lpSystemPowerStatus [out]

A pointer to a SYSTEM_POWER_STATUS structure that receives status information.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0400 or later. For more information, see Using the Windows Headers.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

System Power Status
Power Management Functions
SYSTEM_POWER_STATUS

 

 

Send comments about this topic to Microsoft

Build date: 2/7/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Delphi syntax      Carl Kenner   |   Edit   |   Show History
type
PSystemPowerStatus = ^TSystemPowerStatus;
_SYSTEM_POWER_STATUS = packed record
ACLineStatus : Byte;
BatteryFlag : Byte;
BatteryLifePercent : Byte;
Reserved1 : Byte;
BatteryLifeTime : DWORD;
BatteryFullLifeTime : DWORD;
end;
TSystemPowerStatus = _SYSTEM_POWER_STATUS;
SYSTEM_POWER_STATUS = _SYSTEM_POWER_STATUS;

function GetSystemPowerStatus(var lpSystemPowerStatus: TSystemPowerStatus): BOOL; stdcall; external kernel32 name 'GetSystemPowerStatus';
Tags What's this?: Add a tag
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("kernel32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern bool GetSystemPowerStatus([In, Out] ref SYSTEM_POWER_STATUS systemPowerStatus);
Tags What's this?: Add a tag
Flag as ContentBug
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> Public Shared Function GetSystemPowerStatus(<[In], Out> ByRef systemPowerStatus As SYSTEM_POWER_STATUS) As Boolean
End Function
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker