Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DeviceInformationCollection Class

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Represents a collection of DeviceInformation objects.

public ref class DeviceInformationCollection sealed : IIterable<DeviceInformation ^>, IVectorView<DeviceInformation ^>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DeviceInformationCollection final : IIterable<DeviceInformation>, IVectorView<DeviceInformation>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class DeviceInformationCollection : IEnumerable<DeviceInformation>, IReadOnlyList<DeviceInformation>
Public NotInheritable Class DeviceInformationCollection
Implements IEnumerable(Of DeviceInformation), IReadOnlyList(Of DeviceInformation)
Inheritance
Object Platform::Object IInspectable DeviceInformationCollection
Attributes
Implements

Windows requirements

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

Examples

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;
}

Remarks

Successful completion of FindAllAsync results in a DeviceInformationCollection containing DeviceInformation objects.

Collection member lists

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.

Enumerating the collection in C# or Microsoft Visual Basic

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<T> with a DeviceInformation constraint.

Properties

Name Description
Size

The number of DeviceInformation objects in the collection.

Methods

Name Description
First()

Gets an object that can iterate through the enumerated DeviceInformation objects, starting with the first.

GetAt(UInt32)

Gets the DeviceInformation object at the specified index.

GetMany(UInt32, DeviceInformation[])

Gets a range of DeviceInformation objects.

IndexOf(DeviceInformation, UInt32)

Returns the index of the specified DeviceInformation object in the collection.

Applies to


Feedback

Was this page helpful?