Battery.FromIdAsync(String) Method

Definition

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

public:
 static IAsyncOperation<Battery ^> ^ FromIdAsync(Platform::String ^ deviceId);
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<Battery> FromIdAsync(winrt::hstring const& deviceId);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<Battery> FromIdAsync(string deviceId);
function fromIdAsync(deviceId)
Public Shared Function FromIdAsync (deviceId As String) As IAsyncOperation(Of Battery)

Parameters

deviceId
String

Platform::String

winrt::hstring

The device ID of the battery controller (DeviceId).

Returns

A Battery object that corresponds to the specified battery controller.

Attributes

Remarks

FromIdAsync will return null if the battery controller does not exist and the deviceId value is well-formed. If the deviceId value is not well-formed, such as "AggregateBattery," then the method will fail with STATUS_OBJECT_NAME_INVALID.

You can use a DeviceInformation object for a battery controller to use that object's Id property value as the deviceId parameter in FromIdAsync to create a Battery object

Applies to

See also