-api-id | -api-type |
---|---|
M:Windows.Devices.Enumeration.DeviceInformation.CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String}) |
winrt method |
Creates a DeviceInformation object from a DeviceInformation ID and a list of additional properties.
A string containing the DeviceInformation ID.
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.
An object for starting and managing the asynchronous creation of the DeviceInformation object.
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);
});