Programmatically Finding Available Services on Windows 8.1


Windows 8.1 provides developers access to available devices on a Windows 8.1 computing device through first-class support for device enumeration APIs. By using these APIs, developers can programmatically query for device properties, such as ID, Friendly name, and other device properties.

Device APIs

The Device Enumeration APIs are homed in the Windows.Devices.Enumeration namespace. Devices can be filtered by querying for devices with a specific device interface. The most commonly used device interfaces are:

  • Printers—interface value—"{0ECEF634-6EF0-472A-8085-5AD023ECBCCD}"
  • Webcams—interface value—"{E5323777-F976-4F5B-9B55-B94699C46E44}"
  • Portable devices—interface value—"{6AC27878-A6FA-4155-BA85-F98F491D4F33}"

To query for devices of a specific interface, we use the DeviceInformation call, call the FindAllAsync API, and pass in the filter information. We also can query for devices through the device container approach. In this article, we use the PnpObject class on the Windows.Devices.Enumeration.Pnp namespace to get the device list by calling the FindAllAsync API.

We will explore this more in our hands-on experiment.

Hands On

Create a new Visual Studio 2013 project of type Windows Store Application under the Visual C# project templates. Let's name the project Win8DeviceEnumeration.

Figure 1: The new project

Open MainPage.xaml; add four radio buttons and one button, as shown in the following code. Also, add a ListView.


   <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
      <RadioButton x:Name="radioButtonPrinters" Content="Printers"
         HorizontalAlignment="Left" Margin="158,264,0,0" VerticalAlignment="Top"/>
      <RadioButton x:Name="radioButtonWebcams" Content="Webcams"
         HorizontalAlignment="Left" Margin="161,319,0,0" VerticalAlignment="Top"/>
      <RadioButton x:Name="radioButtonPortableDevices" Content="Portable Devices"
         HorizontalAlignment="Left" Margin="164,376,0,0" VerticalAlignment="Top"/>
      <RadioButton x:Name="radioButtonAll" Content="All"
         HorizontalAlignment="Left" Margin="167,427,0,0" VerticalAlignment="Top"/>
      <Button x:Name="buttonGetDevices" Content="Get Devices"
         HorizontalAlignment="Left" Margin="164,504,0,0" VerticalAlignment="Top"/>
      <ListView x:Name="listBoxDevices" HorizontalAlignment="Left"
         Height="579" Margin="576,96,0,0" VerticalAlignment="Top" Width="490"/>


Next, we implement the code behind for MainPage.xaml. This is where we will query for the devices based on the selected radio button. First, we need to include the necessary namespaces.


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

Next, we will implement the click event handler for the button. In this method, we will look at which radio button was selected to determine whether we need to filter the devices or list all the devices.

async private void buttonGetDevices_Click(object sender, RoutedEventArgs e)
      bool queryForAll = true;
      if ((bool)radioButtonPrinters.IsChecked ||
         (bool)radioButtonWebcams.IsChecked ||
         queryForAll = false;

      if (!queryForAll)
         string deviceInterfaceId = "";
         if ((bool)radioButtonPrinters.IsChecked)
            deviceInterfaceId = "{0ECEF634-6EF0-472A-8085-5AD023ECBCCD}";
         else if ((bool)radioButtonWebcams.IsChecked)
            deviceInterfaceId = "{E5323777-F976-4F5B-9B55-B94699C46E44}";
            deviceInterfaceId = "{6AC27878-A6FA-4155-BA85-F98F491D4F33}";
         var selector = "System.Devices.InterfaceClassGuid:=\"" +
            deviceInterfaceId + "\"";
         var interfaces = await DeviceInformation.FindAllAsync(selector, null);
         foreach (DeviceInformation deviceInterface in interfaces)
         string[] properties = { "System.ItemNameDisplay", "System.Devices.ModelName",
            "System.Devices.Connected" };
         var containers = await PnpObject.FindAllAsync(PnpObjectType.DeviceContainer,
         foreach (PnpObject container in containers)

Our application is now ready. When we run the application, we can see that, depending on our selection, the list of devices that are listed varies.


In this article, we learned how to programmatically find available devices on Windows 8.1. If you want to download the sample code, the zip file is included in the article.

About the Author

Vipul Patel is a technology geek based in Seattle. He can be reached at You can visit his LinkedIn profile at



  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date