DeviceInformationCollection
DeviceInformationCollection
DeviceInformationCollection
DeviceInformationCollection
Class
Definition
Represents a collection of DeviceInformation objects.
public : sealed class DeviceInformationCollection : IIterable, IVectorViewpublic sealed class DeviceInformationCollection : IEnumerable, IReadOnlyListPublic NotInheritable Class DeviceInformationCollection Implements IEnumerable, IReadOnlyList// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
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
Properties
Item[Int32] Item[Int32] Item[Int32] Item[Int32]
Gets the element at the specified index in the read-only list.
This member is not implemented in C++T this[int index] { get; }ReadOnly Property Item(index As Integer) As TT this[int index] { get; }
- index
The zero-based index of the element to get.
- Value
- T T T T
The element at the specified index in the read-only list.
Size Size Size Size
The number of DeviceInformation objects in the collection.
public : unsigned int Size { get; }This member is not implemented in C#This member is not implemented in VB.Net// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The number of DeviceInformation objects in the collection.
Methods
First() First() First() First()
Gets an object that can iterate through the enumerated DeviceInformation objects, starting with the first.
public : IIterator<DeviceInformation> First()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
An object that can iterate through the enumerated devices, starting with the first.
GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32)
Gets the DeviceInformation object at the specified index.
public : DeviceInformation GetAt(unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- index
- unsigned int UInt32 UInt32 UInt32
The index.
The DeviceInformation object at the specified index.
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()
Returns an enumerator that iterates through the collection.
This member is not implemented in C++IEnumerator<T> GetEnumerator()Function GetEnumerator As IEnumerator(Of T)IEnumerator<T> GetEnumerator()
An enumerator that can be used to iterate through the collection.
GetMany(UInt32, DeviceInformation[]) GetMany(UInt32, DeviceInformation[]) GetMany(UInt32, DeviceInformation[]) GetMany(UInt32, DeviceInformation[])
Gets a range of DeviceInformation objects.
public : unsigned int GetMany(unsigned int startIndex, DeviceInformation[] items)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- startIndex
- unsigned int UInt32 UInt32 UInt32
The index at which to start retrieving DeviceInformation objects.
- items
- DeviceInformation[] DeviceInformation[] DeviceInformation[] DeviceInformation[]
The array of DeviceInformation objects starting at the index specified by startIndex.
The number of DeviceInformation objects returned.
IndexOf(DeviceInformation, UInt32) IndexOf(DeviceInformation, UInt32) IndexOf(DeviceInformation, UInt32) IndexOf(DeviceInformation, UInt32)
Returns the index of the specified DeviceInformation object in the collection.
public : PlatForm::Boolean IndexOf(DeviceInformation value, unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
The DeviceInformation object in the collection.
- index
- unsigned int UInt32 UInt32 UInt32
The index.
true if the method succeeded; otherwise, false.