Dela via


Battery Class

Definition

Provides information about a battery controller that is currently connected to the device. For more info, see Get battery information.

public ref class Battery sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Battery final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class Battery
Public NotInheritable Class Battery
Inheritance
Object Platform::Object IInspectable Battery
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

In this context, device refers to the hardware that your app is running on. Battery controller refers to the electronics that interface between the physical battery and the operating system. A battery controller appears in Device Manager as a "Battery" under the Batteries node.

Depending on the device, it may be possible to remove the physical battery while the device remains running. For example, a laptop that's plugged into A/C power. In that case, if the battery controller were part of the laptop enclosure, you could potentially create a Battery object when no battery is connected to the device. However, if the battery controller resided on the physical battery, it would no longer be visible to the operating system and therefore you could not create a corresponding Battery object for an individual battery.

Properties

AggregateBattery

Gets a Battery object that represents all battery controllers connected to the device.

DeviceId

Gets the identifier (ID) for an individual battery controller.

Methods

FromIdAsync(String)

Gets a Battery object that represents an individual battery controller connected to the device.

GetDeviceSelector()

Gets an Advanced Query Syntax (AQS) string that can be used to find all battery controllers that are connected to the device.

GetReport()

Gets a BatteryReport object that indicates the charge, capacity, and status of the battery or aggregate.

Events

ReportUpdated

Occurs when the charge, capacity, or status of a battery changes.

Applies to

See also