DeviceInformation DeviceInformation DeviceInformation DeviceInformation Class

Represents a device. This class allows access to well-known device properties as well as additional properties specified during device enumeration.

Syntax

Declaration

public sealed class DeviceInformationpublic sealed class DeviceInformationPublic NotInheritable Class DeviceInformation

Remarks

A DeviceInformation object is composed of an identity (Id ), a kind (Kind ), and a property bag (Properties ). All of the other properties of a DeviceInformation object are derived from the Properties property bag. For example, Name is derived from System.ItemNameDisplay.

Successful completion of FindAllAsync(System.String) results in a DeviceInformationCollection containing DeviceInformation objects.

If a call to CreateWatcher() succeeds, a DeviceInformation object is passed to the Added event for each device that is found.

The Name property should only be used for display purposes only and not for finding a device because the Name can change due to localization or a user assigning a name.

CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind) creates a DeviceInformation object if successful.

The DeviceInformation class provides device information, but more specifically, it provides properties of the device interface, the interface that represents functionality that the device exposes. Multi-function devices may have more than one device interface. The physical object that a user sees as a device, is known as the device container, and has properties such as Manufacturer and ModelID. For more information about enumerating devices and recovering properties, see Enumerate devices.

Examples

This example incrementally enumerates devices, adding them to a list each time a device is found, and also handling removals and updates.

var watcher;
var isEnumerationComplete = false;
var deviceArray = new Array(); // Saves the enumeration results

function WatchDevices() {
    try {
        output.innerHTML = ""; // clear output field

        watcher = 
            Windows.Devices.Enumeration.DeviceInformation.createWatcher();
        // Add event handlers
        watcher.addEventListener("added", onAdded);
        watcher.addEventListener("removed", onRemoved);
        watcher.addEventListener("updated", onUpdated);
        watcher.addEventListener("enumerationcompleted", 
            onEnumerationCompleted);
        watcher.addEventListener("stopped", onStopped);
        // Start enumerating and listening for events
        watcher.start();
    } catch (e) {
        document.getElementById("statusMessage").innerHTML = 
            "Failed to create watcher, error: " + e.message;
    }
}

function stopWatcher() {
    try {
        watcher.stop();
    }
    catch (e) {
        document.getElementById("statusMessage").innerHTML = 
            "Failed to stop watcher: " + e.message;
    }
}

function onAdded(devinfo) {
    document.getElementById("output").innerHTML += "<p>Device added: " + 
        devinfo.name + "</p>";
    deviceArray.push(devinfo);
    if (isEnumerationComplete) {
        output.innerHTML = ""; // clear output field
        printDeviceArray(document.getElementById("output"));
    }
    
}

function onUpdated(devUpdate) {
    document.getElementById("output").innerHTML += "<p>Device updated.</p>";
    for (var i = 0; i < deviceArray.length; i++) {
        if (deviceArray[i].id == devUpdate.id) {
            deviceArray[i].update(devUpdate);
        }
    }
    output.innerHTML = ""; // clear output field
    printDeviceArray(document.getElementById("output"));
}

function onRemoved(devupdate) {
    document.getElementById("output").innerHTML += "<p>Device removed.</p>";
    for (var i = 0; i < deviceArray.length; i++) {
        if (deviceArray[i].id == devupdate.id) {
            deviceArray[i].slice(devupdate);
        }
    }
    output.innerHTML = ""; // clear output field
    printDeviceArray(document.getElementById("output"));
}

function onEnumerationCompleted(obj) {
    isEnumerationComplete = true;
    document.getElementById("output").innerHTML += 
        "<p>Enumeration Completed.</p>";
    printDeviceArray(document.getElementById("output"));
}

function onStopped(obj) {
    document.getElementById("output").innerHTML += "<p>Stopped.</p>";
    if (watcher.status == Windows.Devices.Enumeration.DeviceWatcherStatus.aborted) {
       document.getElementById("output").innerHTML += 
        "<p>Enumeration stopped unexpectedly. </p>";
       document.getElementById("output").innerHTML += 
        "<p>Click the Watch button to restart enumeration.</p>";
    } else if (watcher.status == Windows.Devices.Enumeration.DeviceWatcherStatus.stopped) {
       document.getElementById("output").innerHTML += 
        "<p>You requested to stop enumeration. </p>";
       document.getElementById("output").innerHTML += 
        "<p>Click the Watch button to restart enumeration.</p>";
    }

}


// Prints the friendly name of the device interface, 
// its ID (device interface path), and whether it is enabled.
function printDevice(deviceInterface, outputDestination) {
    outputDestination.innerHTML += "<p>Name: " + 
        deviceInterface.name + "<p/>"; 
    outputDestination.innerHTML += "<p>Interface ID: " + 
        deviceInterface.id + "<p/>";    
    outputDestination.innerHTML += "<p>Enabled: " + 
        deviceInterface.isEnabled + "<p/>";
    outputDestination.innerHTML += "<br />";
}

function printDeviceArray(outputDestination) {
    for (var i = 0; i < deviceArray.length; i++) {
        printDevice(deviceArray[i], outputDestination);
    }
}
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml.Media.Imaging;

using Windows.Devices.Enumeration;
using Windows.Devices.Enumeration.Pnp;


// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace Application1
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    /// 
    public sealed partial class BlankPage : Page
    {
        public BlankPage()
        {

            this.InitializeComponent();
        }
        Windows.UI.Core.CoreDispatcher dispatcher;
        public static DeviceWatcher watcher = null;
        public static int count = 0;
        public static DeviceInformation[] interfaces = new DeviceInformation[1000];
        public static bool isEnumerationComplete = false;
        public static string StopStatus = null;

        async void WatchDevices(object sender, RoutedEventArgs eventArgs)
        {
            try
            {
                dispatcher = Window.Current.CoreWindow.Dispatcher;
                watcher = DeviceInformation.CreateWatcher();
                // Add event handlers
                watcher.Added += watcher_Added;
                watcher.Removed += watcher_Removed;
                watcher.Updated += watcher_Updated;
                watcher.EnumerationCompleted += watcher_EnumerationCompleted;
                watcher.Stopped += watcher_Stopped;
                watcher.Start();
                OutputText.Text = "Enumeration started.";

            }
            catch (ArgumentException)
            {
                //The ArgumentException gets thrown by FindAllAsync when the GUID isn't formatted properly
                //The only reason we're catching it here is because the user is allowed to enter GUIDs without validation
                //In normal usage of the API, this exception handling probably wouldn't be necessary when using known-good GUIDs 
                OutputText.Text = "Caught ArgumentException. Failed to create watcher.";
            }
        }

        async void StopWatcher(object sender, RoutedEventArgs eventArgs)
        {
            try
            {
                if (watcher.Status == Windows.Devices.Enumeration.DeviceWatcherStatus.Stopped)
                {
                    StopStatus = "The enumeration is already stopped.";
                }
                else
                {
                    watcher.Stop();
                }
            }
            catch (ArgumentException)
            {
                OutputText.Text = "Caught ArgumentException. Failed to stop watcher.";
            }
        }

        async void watcher_Added(DeviceWatcher sender, DeviceInformation deviceInterface)
        {
            interfaces[count] = deviceInterface;
            count += 1;
            if (isEnumerationComplete)
            {
                await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    DisplayDeviceInterfaceArray();
                });
            }
        }

        async void watcher_Updated(DeviceWatcher sender, DeviceInformationUpdate devUpdate)
        {
            int count2 = 0;
            foreach (DeviceInformation deviceInterface in interfaces)
            {
                if (count2 < count)
                {
                    if (interfaces[count2].Id == devUpdate.Id)
                    {
                        //Update the element.
                        interfaces[count2].Update(devUpdate);
                    }

                }
                count2 += 1;
            }
            await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                OutputText.Text = "Enumeration updated. ";
                DisplayDeviceInterfaceArray();
            });
        }

        async void watcher_Removed(DeviceWatcher sender, DeviceInformationUpdate devUpdate)
        {
            int count2 = 0;
            //Convert interfaces array to a list (IList).
            List<DeviceInformation> interfaceList = new List<DeviceInformation>(interfaces);
            foreach (DeviceInformation deviceInterface in interfaces)
            {
                if (count2 < count)
                {
                    if (interfaces[count2].Id == devUpdate.Id)
                    {
                        //Remove the element.
                        interfaceList.RemoveAt(count2);
                    }

                }
                count2 += 1;
            }
            //Convert the list back to the interfaces array.
            interfaces = interfaceList.ToArray();
            count -= 1;
            await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                OutputText.Text = "Enumeration device was removed. ";
                DisplayDeviceInterfaceArray();
            });
        }

        async void watcher_EnumerationCompleted(DeviceWatcher sender, object args)
        {
            isEnumerationComplete = true;
            await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    OutputText.Text = "Enumeration complete. ";
                    DisplayDeviceInterfaceArray();
                });
        }

        async void watcher_Stopped(DeviceWatcher sender, object args)
        {
            if (watcher.Status == Windows.Devices.Enumeration.DeviceWatcherStatus.Aborted)
            {
                StopStatus = "Enumeration stopped unexpectedly. Click Watch to restart enumeration.";
            }
            else if (watcher.Status == Windows.Devices.Enumeration.DeviceWatcherStatus.Stopped)
            {
                StopStatus = "You requested to stop the enumeration. Click Watch to restart enumeration.";
            }
        }

        async void DisplayDeviceInterfaceArray()
        {
            DeviceInterfacesOutputList.Items.Clear();
            int count2 = 0;
            foreach (DeviceInformation deviceInterface in interfaces)
            {
                if (count2 < count)
                {
                    DisplayDeviceInterface(deviceInterface);
                }
                count2 += 1;
            }
        }

        async void DisplayDeviceInterface(DeviceInformation deviceInterface)
        {
            var id = "Id:" + deviceInterface.Id;
            var name = deviceInterface.Name;
            var isEnabled = "IsEnabled:" + deviceInterface.IsEnabled;


            var item = id + " is \n" + name + " and \n" + isEnabled;

            DeviceInterfacesOutputList.Items.Add(item);
        }
    }
}

Properties summary

The physical location of the device in its enclosure. For example, it may describe the location of a webcam inside a laptop.

A string representing the identity of the device.

Indicates whether this device is the default device for the class.

Indicates whether this device is enabled.

Gets the type of DeviceInformation represented by this object.

The name of the device. This name is in the best available language for the app.

Gets the information about the capabilities for this device to pair.

Property store containing well-known values as well as additional properties that can be specified during device enumeration.

Methods summary

Creates a DeviceInformation object from a DeviceInformation ID.

Creates a DeviceInformation object from a DeviceInformation ID and a list of additional properties.

Creates a DeviceInformation object from a DeviceInformation ID, a list of additional properties, and a DeviceInformationKind parameter.

Creates a DeviceWatcher for all devices.

Creates a DeviceWatcher for devices matching the specified Advanced Query Syntax (AQS) string.

Creates a DeviceWatcher for devices matching the specified Advanced Query Syntax (AQS) string and the specified collection of properties.

Creates a DeviceWatcher for devices matching the specified Advanced Query Syntax (AQS) string, the specified collection of properties, and the kind of devices.

Creates a DeviceWatcher for devices matching the specified DeviceClass.

Enumerates all DeviceInformation objects.

Enumerates DeviceInformation objects matching the specified Advanced Query Syntax (AQS) string.

Enumerates DeviceInformation objects matching the specified Advanced Query Syntax (AQS) string and including the specified collection of properties.

Enumerates DeviceInformation objects matching the specified Advanced Query Syntax (AQS) string, the device kind, and including the specified collection of properties.

Enumerates DeviceInformation objects of the specified class.

Creates a filter to use to enumerate through a subset of device types.

Gets a glyph for the device.

Returns a thumbnail image for the device.

Updates the properties of an existing DeviceInformation object.

Properties

  • EnclosureLocation
    EnclosureLocation
    EnclosureLocation
    EnclosureLocation

    The physical location of the device in its enclosure. For example, it may describe the location of a webcam inside a laptop.

    public EnclosureLocation EnclosureLocation { get; }public EnclosureLocation EnclosureLocation { get; }Public ReadOnly Property EnclosureLocation As EnclosureLocation

    Property Value

    Remarks

    If no enclosure location information is available, the property will be null.

  • Id
    Id
    Id
    Id

    A string representing the identity of the device.

    public string Id { get; }public string Id { get; }Public ReadOnly Property Id As string

    Property Value

    • string
      string
      string
      string

      A string representing the identity of the device.

    Remarks

    This ID can be used to activate device functionality using the CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind) methods on classes that implement device functionality.

    The DeviceInformation object that the Id property identifies is actually adevice interface . For simplicity in this documentation, the DeviceInformation object is called a device, and the identifier in its Id property is called a DeviceInformation ID.

  • IsDefault
    IsDefault
    IsDefault
    IsDefault

    Indicates whether this device is the default device for the class.

    public bool IsDefault { get; }public bool IsDefault { get; }Public ReadOnly Property IsDefault As bool

    Property Value

    • bool
      bool
      bool
      bool

      Indicates whether this device is the default device for the class.

  • IsEnabled
    IsEnabled
    IsEnabled
    IsEnabled

    Indicates whether this device is enabled.

    public bool IsEnabled { get; }public bool IsEnabled { get; }Public ReadOnly Property IsEnabled As bool

    Property Value

    • bool
      bool
      bool
      bool

      Indicates whether this device is enabled.

  • Kind
    Kind
    Kind
    Kind

    Gets the type of DeviceInformation represented by this object.

    public DeviceInformationKind Kind { get; }public DeviceInformationKind Kind { get; }Public ReadOnly Property Kind As DeviceInformationKind

    Property Value

  • Name
    Name
    Name
    Name

    The name of the device. This name is in the best available language for the app.

    public string Name { get; }public string Name { get; }Public ReadOnly Property Name As string

    Property Value

    • string
      string
      string
      string

      The name of the device. This name is in the best available language for the app.

    Remarks

    The Name property should only be used for display purposes only and not for finding a device because the Name can change due to localization or a user assigning a name.

  • Pairing
    Pairing
    Pairing
    Pairing

    Gets the information about the capabilities for this device to pair.

    public DeviceInformationPairing Pairing { get; }public DeviceInformationPairing Pairing { get; }Public ReadOnly Property Pairing As DeviceInformationPairing

    Property Value

  • Properties
    Properties
    Properties
    Properties

    Property store containing well-known values as well as additional properties that can be specified during device enumeration.

    public IMapView<string, object> Properties { get; }public IMapView<string, object> Properties { get; }Public ReadOnly Property Properties As IMapView<string, object>

    Property Value

    • The property store for the device.

    Remarks

    For more info on what the properties represent, see Device information properties.

Methods

  • CreateFromIdAsync(System.String)
    CreateFromIdAsync(System.String)
    CreateFromIdAsync(System.String)
    CreateFromIdAsync(System.String)

    Creates a DeviceInformation object from a DeviceInformation ID.

    public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(System.String)public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(System.String)Public Static Function CreateFromIdAsync(System.String) As IAsyncOperation( Of DeviceInformation )

    Parameters

    • deviceId
      System.String
      System.String
      System.String
      System.String

      The device ID.

    Returns

    • An object for starting and managing the asynchronous creation of the DeviceInformation object.

    Remarks

    Examples

    The savedId variable in this example is a DeviceInformation ID previously saved by the application, obtained from the Id property of the last-used DeviceInformation object.

    
        // Create a DeviceInformation object from a saved ID
        var Enum = Windows.Devices.Enumeration;
        var DevInf = Enum.DeviceInformation;
        DevInf.createFromIdAsync(savedId).then(
            function(devinfo) {
                // Use the created DeviceInformation object
                printMessage("Created DeviceInformation. Name: " + devinfo.name);
            },
            function (e) {
                displayError("Failed to create DeviceInformation: " + e.message);
            });
    
  • CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})
    CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})
    CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})
    CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})

    Creates a DeviceInformation object from a DeviceInformation ID and a list of additional properties.

    public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})Public Static Function CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String}) As IAsyncOperation( Of DeviceInformation )

    Parameters

    Returns

    • An object for starting and managing the asynchronous creation of the DeviceInformation object.

    Remarks

    Examples

    The following example builds a list of properties to include in the DeviceInformation object to create from a DeviceInformation ID.The savedId variable in this example is a DeviceInformation ID previously saved by the application, obtained from the Id property of the last-used DeviceInformation object.

    
        // Create a set of two additional properties
        var propertiesToRetrieve = new Array();
        propertiesToRetrieve.push("System.InterfaceClassGuid");
        propertiesToRetrieve.push("System.Storage.IsPortable");
    
        // Create a DeviceInformation object from a saved ID
        var Enum = Windows.Devices.Enumeration;
        var DevInf = Enum.DeviceInformation;
        DevInf.createFromIdAsync(savedId, propertiesToRetrieve).then(
            function(devinfo) {
                // Use the created DeviceInformation object
                printMessage("Created DeviceInformation. Name: " + devinfo.name);
            },
            function (e) {
                displayError("Failed to create DeviceInformation: " + e.message);
            });
    
  • CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)

    Creates a DeviceInformation object from a DeviceInformation ID, a list of additional properties, and a DeviceInformationKind parameter.

    public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)public static IAsyncOperation<DeviceInformation> CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)Public Static Function CreateFromIdAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind) As IAsyncOperation( Of DeviceInformation )

    Parameters

    Returns

    • An object for starting and managing the asynchronous creation of the DeviceInformation object.

  • CreateWatcher()
    CreateWatcher()
    CreateWatcher()
    CreateWatcher()

    Creates a DeviceWatcher for all devices.

    public static DeviceWatcher CreateWatcher()public static DeviceWatcher CreateWatcher()Public Static Function CreateWatcher() As DeviceWatcher

    Returns

    Remarks

    The DeviceWatcher first performs an initial enumeration of devices, raising an Added event for each device that it finds, and raising an EnumerationCompleted event when the initial enumeration is complete. After the initial enumeration is complete, it raises events when a device is added, deleted, or updated.

    See the DeviceWatcher class for an example.

    Note

    An app must subscribe to all of the Added, Removed, and Updated events to be notified when there are device additions, removals or updates. If an app handles only the Added event, it will not receive an update if a device is added to the system after the initial device enumeration completes.

  • CreateWatcher(System.String)
    CreateWatcher(System.String)
    CreateWatcher(System.String)
    CreateWatcher(System.String)

    Creates a DeviceWatcher for devices matching the specified Advanced Query Syntax (AQS) string.

    public static DeviceWatcher CreateWatcher(System.String)public static DeviceWatcher CreateWatcher(System.String)Public Static Function CreateWatcher(System.String) As DeviceWatcher

    Parameters

    • aqsFilter
      System.String
      System.String
      System.String
      System.String

      An AQS string that filters the DeviceInformation objects to enumerate. Typically this string is retrieved from the GetDeviceSelector method of a class that interacts with devices. For example, GetDeviceSelector() retrieves the string for the StorageDevice class.

    Returns

    Remarks

    Note

    This overload is not available from JavaScript. To create a DeviceWatcher from an AQS string in JavaScript, use the CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String}) overload and pass null as the second parameter.

    The DeviceWatcher first performs an initial enumeration of devices, raising an Added event for each device that it finds, and raising an EnumerationCompleted event when the initial enumeration is complete. After the initial enumeration is complete, it raises events when a device is added, deleted, or updated.

    Note

    An app must subscribe to all of the Added, Removed, and Updated events to be notified when there are device additions, removals or updates. If an app handles only the Added event, it will not receive an update if a device is added to the system after the initial device enumeration completes.

    See the DeviceWatcher class for an example.

  • CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String})
    CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String})
    CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String})
    CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String})

    Creates a DeviceWatcher for devices matching the specified Advanced Query Syntax (AQS) string and the specified collection of properties.

    public static DeviceWatcher CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String})public static DeviceWatcher CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String})Public Static Function CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String}) As DeviceWatcher

    Parameters

    • aqsFilter
      System.String
      System.String
      System.String
      System.String

      An AQS string that filters the DeviceInformation objects to enumerate. Typically this string is retrieved from the GetDeviceSelector method of a class that interacts with devices. For example, GetDeviceSelector() retrieves the string for the StorageDevice class.

    • additionalProperties

      An iterable list of additional properties to include in the Properties property of the DeviceInformation objects in the enumeration results. For more info on what the properties represent, see Device information properties.

    Returns

    Remarks

    The DeviceWatcher first performs an initial enumeration of devices, raising an Added event for each device that it finds, and raising an EnumerationCompleted event when the initial enumeration is complete. After the initial enumeration is complete, it raises events when a device is added, deleted, or updated.

    Note

    An app must subscribe to all of the Added, Removed, and Updated events to be notified when there are device additions, removals or updates. If an app handles only the Added event, it will not receive an update if a device is added to the system after the initial device enumeration completes.

    See the DeviceWatcher class for an example.

  • CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)

    Creates a DeviceWatcher for devices matching the specified Advanced Query Syntax (AQS) string, the specified collection of properties, and the kind of devices.

    public static DeviceWatcher CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)public static DeviceWatcher CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)Public Static Function CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind) As DeviceWatcher

    Parameters

    Returns

  • CreateWatcher(Windows.Devices.Enumeration.DeviceClass)
    CreateWatcher(Windows.Devices.Enumeration.DeviceClass)
    CreateWatcher(Windows.Devices.Enumeration.DeviceClass)
    CreateWatcher(Windows.Devices.Enumeration.DeviceClass)

    Creates a DeviceWatcher for devices matching the specified DeviceClass.

    public static DeviceWatcher CreateWatcher(Windows.Devices.Enumeration.DeviceClass)public static DeviceWatcher CreateWatcher(Windows.Devices.Enumeration.DeviceClass)Public Static Function CreateWatcher(Windows.Devices.Enumeration.DeviceClass) As DeviceWatcher

    Parameters

    Returns

    Remarks

    The DeviceWatcher first performs an initial enumeration of devices, raising an Added event for each device that it finds, and raising an EnumerationCompleted event when the initial enumeration is complete. After the initial enumeration is complete, it raises events when a device is added, deleted, or updated.

    Note

    An app must subscribe to all of the Added, Removed, and Updated events to be notified when there are device additions, removals or updates. If an app handles only the Added event, it will not receive an update if a device is added to the system after the initial device enumeration completes.

    See the DeviceWatcher class for an example.

  • FindAllAsync()
    FindAllAsync()
    FindAllAsync()
    FindAllAsync()

    Enumerates all DeviceInformation objects.

    public static IAsyncOperation<DeviceInformationCollection> FindAllAsync()public static IAsyncOperation<DeviceInformationCollection> FindAllAsync()Public Static Function FindAllAsync() As IAsyncOperation( Of DeviceInformationCollection )

    Returns

    • The object for managing the asynchronous operation.

  • FindAllAsync(System.String)
    FindAllAsync(System.String)
    FindAllAsync(System.String)
    FindAllAsync(System.String)

    Enumerates DeviceInformation objects matching the specified Advanced Query Syntax (AQS) string.

    public static IAsyncOperation<DeviceInformationCollection> FindAllAsync(System.String)public static IAsyncOperation<DeviceInformationCollection> FindAllAsync(System.String)Public Static Function FindAllAsync(System.String) As IAsyncOperation( Of DeviceInformationCollection )

    Parameters

    • aqsFilter
      System.String
      System.String
      System.String
      System.String

      An AQS string that filters the DeviceInformation objects to enumerate. Typically this string is retrieved from the GetDeviceSelector method of a class that interacts with devices. For example, GetDeviceSelector() retrieves the string for the StorageDevice class.

    Returns

    • The object for managing the asynchronous operation.

    Remarks

    Important

    This method is not available using JavaScript. If you try to use it, your code will instead call FindAllAsync(Windows.Devices.Enumeration.DeviceClass) with an invalid class and return a collection with all devices. Instead, you should use FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String}) with null as the second parameter if no other properties are needed.

  • FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})
    FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})
    FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})
    FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})

    Enumerates DeviceInformation objects matching the specified Advanced Query Syntax (AQS) string and including the specified collection of properties.

    public static IAsyncOperation<DeviceInformationCollection> FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})public static IAsyncOperation<DeviceInformationCollection> FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String})Public Static Function FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String}) As IAsyncOperation( Of DeviceInformationCollection )

    Parameters

    • aqsFilter
      System.String
      System.String
      System.String
      System.String

      An AQS string that filters the DeviceInformation objects to enumerate. Typically this string is retrieved from the GetDeviceSelector method of a class that interacts with devices. For example, GetDeviceSelector() retrieves the string for the StorageDevice class.

    • additionalProperties

      An iterable list of additional properties to include in the Properties property of the DeviceInformation objects in the enumeration results. For more info on what the properties represent, see Device information properties.

    Returns

    • The object for managing the asynchronous operation.

  • FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)
    FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)

    Enumerates DeviceInformation objects matching the specified Advanced Query Syntax (AQS) string, the device kind, and including the specified collection of properties.

    public static IAsyncOperation<DeviceInformationCollection> FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)public static IAsyncOperation<DeviceInformationCollection> FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind)Public Static Function FindAllAsync(System.String,Windows.Foundation.Collections.IIterable{System.String},Windows.Devices.Enumeration.DeviceInformationKind) As IAsyncOperation( Of DeviceInformationCollection )

    Parameters

    Returns

    • The object for managing the asynchronous operation.

  • FindAllAsync(Windows.Devices.Enumeration.DeviceClass)
    FindAllAsync(Windows.Devices.Enumeration.DeviceClass)
    FindAllAsync(Windows.Devices.Enumeration.DeviceClass)
    FindAllAsync(Windows.Devices.Enumeration.DeviceClass)

    Enumerates DeviceInformation objects of the specified class.

    public static IAsyncOperation<DeviceInformationCollection> FindAllAsync(Windows.Devices.Enumeration.DeviceClass)public static IAsyncOperation<DeviceInformationCollection> FindAllAsync(Windows.Devices.Enumeration.DeviceClass)Public Static Function FindAllAsync(Windows.Devices.Enumeration.DeviceClass) As IAsyncOperation( Of DeviceInformationCollection )

    Parameters

    Returns

    • The object for managing the asynchronous operation.

  • GetAqsFilterFromDeviceClass(Windows.Devices.Enumeration.DeviceClass)
    GetAqsFilterFromDeviceClass(Windows.Devices.Enumeration.DeviceClass)
    GetAqsFilterFromDeviceClass(Windows.Devices.Enumeration.DeviceClass)
    GetAqsFilterFromDeviceClass(Windows.Devices.Enumeration.DeviceClass)

    Creates a filter to use to enumerate through a subset of device types.

    public static string GetAqsFilterFromDeviceClass(Windows.Devices.Enumeration.DeviceClass)public static string GetAqsFilterFromDeviceClass(Windows.Devices.Enumeration.DeviceClass)Public Static Function GetAqsFilterFromDeviceClass(Windows.Devices.Enumeration.DeviceClass) As string

    Parameters

    Returns

    • string
      string
      string
      string

      The Advanced Query Syntax (AQS) filter used to specifically enumerate through the device type specified by deviceClass.

  • GetGlyphThumbnailAsync()
    GetGlyphThumbnailAsync()
    GetGlyphThumbnailAsync()
    GetGlyphThumbnailAsync()

    Gets a glyph for the device.

    public IAsyncOperation<DeviceThumbnail> GetGlyphThumbnailAsync()public IAsyncOperation<DeviceThumbnail> GetGlyphThumbnailAsync()Public Function GetGlyphThumbnailAsync() As IAsyncOperation( Of DeviceThumbnail )

    Returns

    • The object for managing the asynchronous operation that will return a DeviceThumbnail

  • GetThumbnailAsync()
    GetThumbnailAsync()
    GetThumbnailAsync()
    GetThumbnailAsync()

    Returns a thumbnail image for the device.

    public IAsyncOperation<DeviceThumbnail> GetThumbnailAsync()public IAsyncOperation<DeviceThumbnail> GetThumbnailAsync()Public Function GetThumbnailAsync() As IAsyncOperation( Of DeviceThumbnail )

    Returns

    • The object for managing the asynchronous operation that will return a DeviceThumbnail.

  • Update(Windows.Devices.Enumeration.DeviceInformationUpdate)
    Update(Windows.Devices.Enumeration.DeviceInformationUpdate)
    Update(Windows.Devices.Enumeration.DeviceInformationUpdate)
    Update(Windows.Devices.Enumeration.DeviceInformationUpdate)

    Updates the properties of an existing DeviceInformation object.

    public void Update(Windows.Devices.Enumeration.DeviceInformationUpdate)public void Update(Windows.Devices.Enumeration.DeviceInformationUpdate)Public Function Update(Windows.Devices.Enumeration.DeviceInformationUpdate) As void

    Parameters

    Remarks

    For more info on what the properties represent, see Device information properties.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.StaticAttribute

Details

Assembly

Windows.Devices.Enumeration.dll