Dela via


DeviceInformation.CreateFromIdAsync Method

Definition

Overloads

CreateFromIdAsync(String)

Creates a DeviceInformation object from a DeviceInformation ID.

CreateFromIdAsync(String, IIterable<String>)

Creates a DeviceInformation object from a DeviceInformation ID and a list of additional properties.

CreateFromIdAsync(String, IIterable<String>, DeviceInformationKind)

Creates a DeviceInformation object from a DeviceInformation ID, a list of additional properties, and a DeviceInformationKind parameter.

CreateFromIdAsync(String, IIterable<String>, DeviceInformationKind, IDeviceEnumerationSettings)

Asynchronously creates a DeviceInformation object from a DeviceInformation ID, a list of additional properties, a DeviceInformationKind, and a settings object.

CreateFromIdAsync(String)

Creates a DeviceInformation object from a DeviceInformation ID.

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

Parameters

deviceId
String

Platform::String

winrt::hstring

The device ID.

Returns

An object for starting and managing the asynchronous creation of the DeviceInformation object.

Attributes

Examples

The savedId variable in this example is a DeviceInformation ID previously saved by the application, obtained from the id property of the last-used DeviceInformation object.

// Create a DeviceInformation object from a saved ID
var Enum = Windows.Devices.Enumeration;
var DevInf = Enum.DeviceInformation;
DevInf.createFromIdAsync(savedId).then(
    function(devinfo) {
        // Use the created DeviceInformation object
        printMessage("Created DeviceInformation. Name: " + devinfo.name);
    },
    function (e) {
        displayError("Failed to create DeviceInformation: " + e.message);
    });

See also

Applies to

CreateFromIdAsync(String, IIterable<String>)

Creates a DeviceInformation object from a DeviceInformation ID and a list of additional properties.

public:
 static IAsyncOperation<DeviceInformation ^> ^ CreateFromIdAsync(Platform::String ^ deviceId, IIterable<Platform::String ^> ^ additionalProperties);
/// [Windows.Foundation.Metadata.Overload("CreateFromIdAsyncAdditionalProperties")]
 static IAsyncOperation<DeviceInformation> CreateFromIdAsync(winrt::hstring const& deviceId, IIterable<winrt::hstring> const& additionalProperties);
[Windows.Foundation.Metadata.Overload("CreateFromIdAsyncAdditionalProperties")]
public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(string deviceId, IEnumerable<string> additionalProperties);
function createFromIdAsync(deviceId, additionalProperties)
Public Shared Function CreateFromIdAsync (deviceId As String, additionalProperties As IEnumerable(Of String)) As IAsyncOperation(Of DeviceInformation)

Parameters

deviceId
String

Platform::String

winrt::hstring

A string containing the DeviceInformation ID.

additionalProperties

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

An iterable list of additional properties to include in the Properties property of the DeviceInformation objects in the enumeration results. For more info on what the properties represent, see Device information properties.

Returns

An object for starting and managing the asynchronous creation of the DeviceInformation object.

Attributes

Examples

The following example builds a list of properties to include in the DeviceInformation object to create from a DeviceInformation ID.The savedId variable in this example is a DeviceInformation ID previously saved by the application, obtained from the id property of the last-used DeviceInformation object.

// Create a set of two additional properties
var propertiesToRetrieve = new Array();
propertiesToRetrieve.push("System.InterfaceClassGuid");
propertiesToRetrieve.push("System.Storage.IsPortable");

// Create a DeviceInformation object from a saved ID
var Enum = Windows.Devices.Enumeration;
var DevInf = Enum.DeviceInformation;
DevInf.createFromIdAsync(savedId, propertiesToRetrieve).then(
    function(devinfo) {
        // Use the created DeviceInformation object
        printMessage("Created DeviceInformation. Name: " + devinfo.name);
    },
    function (e) {
        displayError("Failed to create DeviceInformation: " + e.message);
    });

See also

Applies to

CreateFromIdAsync(String, IIterable<String>, DeviceInformationKind)

Creates a DeviceInformation object from a DeviceInformation ID, a list of additional properties, and a DeviceInformationKind parameter.

public:
 static IAsyncOperation<DeviceInformation ^> ^ CreateFromIdAsync(Platform::String ^ deviceId, IIterable<Platform::String ^> ^ additionalProperties, DeviceInformationKind kind);
/// [Windows.Foundation.Metadata.Overload("CreateFromIdAsyncWithKindAndAdditionalProperties")]
 static IAsyncOperation<DeviceInformation> CreateFromIdAsync(winrt::hstring const& deviceId, IIterable<winrt::hstring> const& additionalProperties, DeviceInformationKind const& kind);
[Windows.Foundation.Metadata.Overload("CreateFromIdAsyncWithKindAndAdditionalProperties")]
public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(string deviceId, IEnumerable<string> additionalProperties, DeviceInformationKind kind);
function createFromIdAsync(deviceId, additionalProperties, kind)
Public Shared Function CreateFromIdAsync (deviceId As String, additionalProperties As IEnumerable(Of String), kind As DeviceInformationKind) As IAsyncOperation(Of DeviceInformation)

Parameters

deviceId
String

Platform::String

winrt::hstring

A string containing the DeviceInformation ID.

additionalProperties

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

An iterable list of additional properties to include in the Properties property of the DeviceInformation objects in the enumeration results. For more info on what the properties represent, see Device information properties.

kind
DeviceInformationKind

The type of DeviceInformation object you want to create.

Returns

An object for starting and managing the asynchronous creation of the DeviceInformation object.

Attributes

See also

Applies to

CreateFromIdAsync(String, IIterable<String>, DeviceInformationKind, IDeviceEnumerationSettings)

Asynchronously creates a DeviceInformation object from a DeviceInformation ID, a list of additional properties, a DeviceInformationKind, and a settings object.

public:
 static IAsyncOperation<DeviceInformation ^> ^ CreateFromIdAsync(Platform::String ^ deviceId, IIterable<Platform::String ^> ^ additionalProperties, DeviceInformationKind kind, IDeviceEnumerationSettings ^ settings);
/// [Windows.Foundation.Metadata.Overload("CreateFromIdAsyncWithAdditionalPropertiesKindAndSettings")]
 static IAsyncOperation<DeviceInformation> CreateFromIdAsync(winrt::hstring const& deviceId, IIterable<winrt::hstring> const& additionalProperties, DeviceInformationKind const& kind, IDeviceEnumerationSettings const& settings);
[Windows.Foundation.Metadata.Overload("CreateFromIdAsyncWithAdditionalPropertiesKindAndSettings")]
public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(string deviceId, IEnumerable<string> additionalProperties, DeviceInformationKind kind, IDeviceEnumerationSettings settings);
function createFromIdAsync(deviceId, additionalProperties, kind, settings)
Public Shared Function CreateFromIdAsync (deviceId As String, additionalProperties As IEnumerable(Of String), kind As DeviceInformationKind, settings As IDeviceEnumerationSettings) As IAsyncOperation(Of DeviceInformation)

Parameters

deviceId
String

Platform::String

winrt::hstring

A string containing the DeviceInformation ID.

additionalProperties

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

An iterable list of additional properties to include in the Properties property of the DeviceInformation object in the enumeration results. For more info about what the properties represent, see Device information properties.

kind
DeviceInformationKind

The type of DeviceInformation object that you want to create.

settings
IDeviceEnumerationSettings

The argument passed in settings is an object that implements IDeviceEnumerationSettings; but otherwise, the object is of an opaque marker class (that is, it has no public properties or methods). The purpose of settings is to retrieve extended parameters from a device-specific API for device-specific scenarios that aren't possible in the standard WDE API. You can think of the parameters like extra knobs that the API surface doesn't allow.

The settings object would come from a device API's GetDeviceEnumerationSettings method, and would contain opaque data. But currently there are no APIs that produce the object.

Returns

An asynchronous operation object which, when it completes, contains a newly created DeviceInformation object.

Attributes

Windows requirements

Device family
Windows 11, version 24H2 (introduced in 10.0.26100.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v19.0)

Applies to