SYSTEM_POWER_STATUS structure
Applies to: desktop apps only
Contains information about the power status of the system.
Syntax
typedef struct _SYSTEM_POWER_STATUS {
BYTE ACLineStatus;
BYTE BatteryFlag;
BYTE BatteryLifePercent;
BYTE Reserved1;
DWORD BatteryLifeTime;
DWORD BatteryFullLifeTime;
} SYSTEM_POWER_STATUS, *LPSYSTEM_POWER_STATUS;
Members
- ACLineStatus
-
The AC power status. This member can be one of the following values.
Value Meaning - 0
Offline
- 1
Online
- 255
Unknown status
- BatteryFlag
-
The battery charge status. This member can contain one or more of the following flags.
Value Meaning - 1
High—the battery capacity is at more than 66 percent
- 2
Low—the battery capacity is at less than 33 percent
- 4
Critical—the battery capacity is at less than five percent
- 8
Charging
- 128
No system battery
- 255
Unknown status—unable to read the battery flag information
The value is zero if the battery is not being charged and the battery capacity is between low and high.
- BatteryLifePercent
-
The percentage of full battery charge remaining. This member can be a value in the range 0 to 100, or 255 if status is unknown.
- Reserved1
-
Reserved; must be zero.
- BatteryLifeTime
-
The number of seconds of battery life remaining, or –1 if remaining seconds are unknown.
- BatteryFullLifeTime
-
The number of seconds of battery life when at full charge, or –1 if full battery lifetime is unknown.
Remarks
The system is only capable of estimating BatteryFullLifeTime based on calculations on BatteryLifeTime and BatteryLifePercent. Without smart battery subsystems, this value may not be accurate enough to be useful.
Requirements
|
Minimum supported client | Windows XP |
|---|---|
|
Minimum supported server | Windows Server 2003 |
|
Header |
|
See also
Send comments about this topic to Microsoft
Build date: 2/7/2012
DllCall('Kernel32.dll','bool','GetSystemPowerStatus','ptr',DllStructGetPtr($_SYSTEM_POWER_STATUS))
MsgBox(32,"电池状态",DllStructGetData($_SYSTEM_POWER_STATUS,1,2))
MsgBox(32,"电源状态",DllStructGetData($_SYSTEM_POWER_STATUS,1,1))
MsgBox(32,"电源状态百分比",DllStructGetData($_SYSTEM_POWER_STATUS,1,3))
MsgBox(32,"电池剩余时间(DWORD)",DllStructGetData($_SYSTEM_POWER_STATUS,2,1))
MsgBox(32,"电池总的时间(DWORD)",DllStructGetData($_SYSTEM_POWER_STATUS,2,2))
- 2/3/2011
- thegfw
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEM_POWER_STATUS
{
public byte ACLineStatus;
public byte BatteryFlag;
public byte BatteryLifePercent;
public byte Reserved1;
public int BatteryLifeTime;
public int BatteryFullLifeTime;
}
- 4/25/2009
- dmex
<StructLayout(LayoutKind.Sequential)> _ Public Structure SYSTEM_POWER_STATUS Public ACLineStatus As Byte Public BatteryFlag As Byte Public BatteryLifePercent As Byte Public Reserved1 As Byte Public BatteryLifeTime As Integer Public BatteryFullLifeTime As Integer End Structure
- 4/25/2009
- dmex