-api-id | -api-type |
---|---|
T:Windows.Devices.Enumeration.DeviceInformationCollection |
winrt class |
Represents a collection of DeviceInformation objects.
Successful completion of FindAllAsync results in a DeviceInformationCollection containing DeviceInformation objects.
For JavaScript, DeviceInformationCollection has the members shown in the member lists. In addition, DeviceInformationCollection supports a length property, members of Array.prototype, and using an index to access items.
DeviceInformationCollection is enumerable, so you can use language-specific syntax such as foreach in C# to enumerate the items in the collection. The compiler does the type-casting for you and you won't need to cast to IEnumerable<DeviceInformation>
explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable with a DeviceInformation constraint.
var DeviceInformation = Enumeration.DeviceInformation;
DeviceInformation.findAllAsync(deviceClass).then(
successCallback,
errorCallback
);
// Handles successful completion of the findAllAsync method.
function successCallback(deviceInformationCollection) {
var numDevices = deviceInformationCollection.length;
document.getElementById("statusMessage").innerHTML =
numDevices + " device interface(s) found";
if (numDevices) {
for (var i = 0; i < numDevices; i++) {
printFriendlyNameAndID(deviceInformationCollection[i],
document.getElementById("Output"));
}
} else {
document.getElementById("statusMessage").innerHTML = "No devices found";
}
}
// Handles an error completion of the findAllAsync method.
function errorCallback(e) {
document.getElementById("statusMessage").innerHTML =
"Failed to find devices, error: " + e.message;
}