DeviceInformationCollection DeviceInformationCollection DeviceInformationCollection DeviceInformationCollection Class

Definition

Represents a collection of DeviceInformation objects.

public sealed class DeviceInformationCollectionpublic sealed class DeviceInformationCollectionPublic NotInheritable Class DeviceInformationCollectionpublic sealed class DeviceInformationCollection
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Successful completion of FindAllAsync(String) 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;
}

Properties

Size Size Size Size

The number of DeviceInformation objects in the collection.

public uint Size { get; }public uint Size { get; }Public ReadOnly Property Size As uintpublic uint Size { get; }
Value
uint uint uint uint

The number of DeviceInformation objects in the collection.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Methods

First() First() First() First()

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

public IIterator<DeviceInformation> First()public IIterator<DeviceInformation> First()Public Function First() As IIterator( Of DeviceInformation )public IIterator<DeviceInformation> First()
Returns

An object that can iterate through the enumerated devices, starting with the first.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32)

Gets the DeviceInformation object at the specified index.

public DeviceInformation GetAt(UInt32 index)public DeviceInformation GetAt(UInt32 index)Public Function GetAt(index As UInt32) As DeviceInformationpublic DeviceInformation GetAt(UInt32 index)
Parameters
index
System.UInt32 System.UInt32 System.UInt32 System.UInt32

The index.

Returns
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

GetMany(UInt32, DeviceInformation[]) GetMany(UInt32, DeviceInformation[]) GetMany(UInt32, DeviceInformation[]) GetMany(UInt32, DeviceInformation[])

Gets a range of DeviceInformation objects.

public uint GetMany(UInt32 startIndex, DeviceInformation[] items)public uint GetMany(UInt32 startIndex, DeviceInformation[] items)Public Function GetMany(startIndex As UInt32, items As DeviceInformation[]) As uintpublic uint GetMany(UInt32 startIndex, DeviceInformation[] items)
Parameters
startIndex
System.UInt32 System.UInt32 System.UInt32 System.UInt32

The index at which to start retrieving DeviceInformation objects.

items
Windows.Devices.Enumeration.DeviceInformation[] Windows.Devices.Enumeration.DeviceInformation[] Windows.Devices.Enumeration.DeviceInformation[] Windows.Devices.Enumeration.DeviceInformation[]

The array of DeviceInformation objects starting at the index specified by startIndex.

Returns
uint uint uint uint

The number of DeviceInformation objects returned.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

IndexOf(DeviceInformation, UInt32) IndexOf(DeviceInformation, UInt32) IndexOf(DeviceInformation, UInt32) IndexOf(DeviceInformation, UInt32)

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

public bool IndexOf(DeviceInformation value, UInt32 index)public bool IndexOf(DeviceInformation value, UInt32 index)Public Function IndexOf(value As DeviceInformation, index As UInt32) As boolpublic bool IndexOf(DeviceInformation value, UInt32 index)
Parameters
index
System.UInt32 System.UInt32 System.UInt32 System.UInt32

The index.

Returns
bool bool bool bool

true if the method succeeded; otherwise, false.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)