Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DeviceInformationCollection class

Represents a collection of DeviceInformation objects.

Syntax

Public NotInheritable Class DeviceInformationCollection
    Implements IReadOnlyList(Of DeviceInformation), _
    IEnumerable(Of DeviceInformation)

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Version(0x06020000)]

Members

The DeviceInformationCollection class has these types of members:

Methods

The DeviceInformationCollection class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
First [C++, JavaScript]Gets an object that can iterate through the enumerated DeviceInformation objects, starting with the first.
GetAt [C++, JavaScript]Gets the DeviceInformation object at the specified index.
GetMany [C++, JavaScript]Gets a range of DeviceInformation objects.
IndexOf [C++, JavaScript]Returns the index of the specified DeviceInformation object in the collection.

 

Properties

The DeviceInformationCollection class has these properties.

PropertyAccess typeDescription

Count [C#, VB]

Read-onlyGets the number of elements contained in the collection.

Item [C#, VB]

Read-onlyGets or sets the element at the specified index.

Size [C++, JavaScript]

Read-onlyThe number of DeviceInformation objects in the collection.

 

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.

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


Requirements

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Namespace

Windows.Devices.Enumeration
Windows::Devices::Enumeration [C++]

Metadata

Windows.winmd

 

 

Show:
© 2014 Microsoft. All rights reserved.