System.Machine.PowerStatus.batteryStatus Property
Gets the charge state of the computer's battery.
This property is read-only.
Syntax
propVal = System.Machine.PowerStatus.batteryStatus()
Parameters
intBatteryStatus [out]
Retrieves the charge state of the battery.Value Meaning 0 BATTERYSTATUS_MEDIUM: The battery capacity is between 33% and 66%.
1 BATTERYSTATUS_HIGH: The battery capacity is over 66%.
2 BATTERYSTATUS_LOW: The battery capacity is under 33%.
4 BATTERYSTATUS_CRITICAL: The battery capacity is under 5%.
128 BATTERYSTATUS_NOBATTERY: No battery detected. The battery is not connected, not charging, and not providing power to the computer.
255 BATTERYSTATUS_UNKNOWN: Unknown battery status. The battery is not responding.
Remarks
If the computer is plugged in, batteryStatus will not indicate the charge state.
Users can redefine LOW and CRITICAL charge states in Control Panel|Power Options|Change plan settings|Change advanced power settings|Battery settings.
Examples
The following example demonstrates how to get the power supply information for the computer.
// --------------------------------------------------------------------
// Get the machine power information.
// --------------------------------------------------------------------
function GetPowerStatus()
{
if (System.Machine.PowerStatus.isPowerLineConnected == false)
{
sMachinePowerInfo = "Power Supply: Battery<br/>";
sMachinePowerInfo += "Battery Capacity Remaining: " + System.Machine.batteryCapacityRemaining + "<br/>";
sMachinePowerInfo += "Battery Capacity Total: " + System.Machine.batteryCapacityTotal + "<br/>";
sMachinePowerInfo += "Battery Percent Remaining: " + System.Machine.batteryPercentRemaining + "<br/>";
sMachinePowerInfo += "Battery Status: " + System.Machine.batteryStatus + "<br/>";
sMachinePowerInfo += "Is Battery Charging: " + System.Machine.isBatteryCharging + "<br/>";
sMachinePowerInfo += "Available Memory: " + System.Machine.availableMemory + "<br/>";
}
else
{
sMachinePowerInfo += "Power Supply: Plugged in<br/>";
}
return sMachinePowerInfo;
}
Requirements
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
IDL | Sidebar.idl |
DLL | Sidebar.Exe version 1.00 or later |
See Also
Send comments about this topic to Microsoft
Build date: 2/24/2010
Build type: SDK