System.Machine.PowerStatus.powerLineStatusChanged Event

Event fired when the computer's power supply state changes between plugged-in and battery-powered.

Syntax

retVal = System.Machine.PowerStatus.powerLineStatusChanged(
  handler
)

Parameters

  • handler
    The name of the function to call when the event is fired.

Remarks

Useful for toggling the display of a battery gauge when the computer is unplugged.

Examples

The following example demonstrates how to get the power supply information for the computer.

// Delegate for the power status change event.
System.Machine.PowerStatus.powerLineStatusChanged = PowerStatus;

// --------------------------------------------------------------------
// Handle the power status changed event.
// --------------------------------------------------------------------
function PowerStatus()
{
    machinePowerInfo.innerHTML = GetPowerStatus();
}

// --------------------------------------------------------------------
// 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

System.Machine.PowerStatus

 

 

Send comments about this topic to Microsoft

Build date: 2/24/2010

Build type: SDK