Share via


How to retrieve additional properties for a device or PnP object (HTML)

Describes how to get additional device properties from a DeviceInformation or PnpObject.

Specifying additional properties

By default, findAllAsync and createWatcher return DeviceInformation objects that have the following properties:

Property Canonical name
Id Not applicable. This property is the identity of the object.
Name System.ItemNameDisplay
IsDefault System.Devices.IsDefault
IsEnabled System.Devices.InterfaceEnabled
EnclosureLocation System.Devices.PhysicalDeviceLocation

 

You can use the overloaded forms of the findAllAsync and createWatcher methods that are available on the DeviceInformation and PnpObject classes. You can specify additional properties to include in the results by using the additionalProperties parameter, as follows.



// Create a set of two additional properties.
    var propertiesToRetrieve = new Array();
    propertiesToRetrieve.push("System.Devices.InterfaceClassGuid");
    propertiesToRetrieve.push("System.Devices.ContainerId");

    Windows.Devices.Enumeration.findAllAsync(selectorString, 
             propertiesToRetrieve).then(successCallback, errorCallback);)

// Handles successful completion of the findAllAsync method.
function successCallback(deviceInformationCollection) {
    var numDevices = deviceInformationCollection.length;
    if (numDevices) {
        for (var i = 0; i < numDevices; i++) {
            printProperties(document.getElementById("log"),
                 deviceInformationCollection[i].properties);
        }
    } 
}

// Handles an error completion of the findAllAsync method.
function errorCallback(e) {
    document.getElementById("statusMessage").innerHTML = 
        "Failed to find devices, error: " + e.message;
}

function printProperties(log, prop) {
    log.innerHTML += "property store count is: " + prop.size;
    var pt = prop.first();
    while (pt.hasCurrent) {
        log.innerHTML += "<br />" + pt.current.key + " := " + pt.current.value;
        pt.moveNext();
    }
    log.innerHTML += "<br />";
}

List of canonical properties

If a property value is not associated with a particular device interface, it may be associated with the device that the interface is part of, or the device container object that represents the visible aspects of a device hardware product, such as manufacturer or model name. The following are lists of property names for device interfaces, devices, and device containers. See Retrieving related PnP objects to learn how to navigate between object types.

Device interface properties

Name Property Description

System.Devices.ContainerId

DEVPKEY_Device_ContainerId

The ID of the device interface's container.

System.Devices.DeviceInstanceId

DEVPKEY_Device_InstanceId

The device instance ID of the device that this interface belongs to.

System.Devices.InterfaceClassGuid

DEVPKEY_DeviceInterface_ClassGuid

Class GUID of the interface.

System.Devices.InterfaceEnabled

DEVPKEY_DeviceInterface_Enabled

Indicates whether the interface is enabled.

System.ItemNameDisplay

DEVPKEY_NAME

The friendly name of the device interface.

System.Storage.IsMediaRemovable

DEVPKEY_Storage_Removable_Media

Indicates whether the volume's media is removable.

System.Storage.IsPortable

DEVPKEY_Storage_Portable

Indicates whether the storage stack considers the storage as portable.

 

Device properties

Name Property Description

System.Devices.Children

DEVPKEY_Device_Children

The device instance IDs of the children. Queried live from kernel state.

System.Devices.CompatibleIds

DEVPKEY_Device_CompatibleIds

This property is a multi-sz string value that contains the list of compatible IDs for the device.

System.Devices.ContainerId

DEVPKEY_Device_ContainerId

The ID of the device's container.

System.Devices.DeviceCapabilities

DEVPKEY_Device_Capabilities

This property is a DWORD value that contains a bitwise OR of a device’s capabilities. These capabilities are represented by CM_DEVCAP_Xxxxx bit masks that are defined in cfgmgr32.h.

System.Devices.DeviceCharacteristics

DEVPKEY_Device_Characteristics

This property is a DWORD value that contains a bitwise OR of a device’s characteristics. For a description of these flags, which are defined in wdm.h and ntddk.h, see the IoCreateDevice function’s DeviceCharacteristics parameter.

System.Devices.DeviceHasProblem

DEVPKEY_Device_HasProblem

This property is queried live from kernel state.

System.Devices.DeviceInstanceId

DEVPKEY_Device_InstanceId

The device instance ID.

System.Devices.HardwareIds

DEVPKEY_Device_HardwareIds

This property is a multi-sz string value that contains the list of hardware IDs for the device.

System.Devices.InLocalMachineContainer

DEVPKEY_Device_InLocalMachineContainerr

Indicates whether the devnode is in the computer's container.

System.ItemNameDisplay

DEVPKEY_NAME

The name of the device instance.

 

Container properties

Name Property and Description
System.ItemNameDisplay PKEY_NAME - Name of the container.
System.Devices.DiscoveryMethod DEVPKEY_DeviceContainer_DiscoveryMethod - List of device discovery methods.
System.Devices.Connected DEVPKEY_DeviceContainer_IsConnected - Indicates if the device is connected.
System.Devices.Paired DEVPKEY_DeviceContainer_IsPaired - Indicates if the device is paired.
System.Devices.Icon DEVPKEY_DeviceContainer_Icon - Path to the device icon.
System.Devices.LocalMachine DEVPKEY_DeviceContainer_IsLocalMachine - Whether this container represents the local machine (PC) or not.
System.Devices.MetadataPath DEVPKEY_DeviceContainer_MetadataPath - Path to device metadata.
System.Devices.LaunchDeviceStageFromExplorer DEVPKEY_DeviceContainer_LaunchDeviceStageFromExlplorer - Whether to launch Device Stage from Windows Explorer.
System.Devices.DeviceDescription1 DEVPKEY_DeviceContainer_DeviceDescription1 - Device description.
System.Devices.DeviceDescription2 DEVPKEY_DeviceContainer_DeviceDescription2 - Device description.
System.Devices.NotWorkingProperly DEVPKEY_DeviceContainer_HasProblem - Whether the container has a problem or not. TRUE if any present device in the container has DEVPKEY_DEVICE_HasProblem set to TRUE.
System.Devices.IsShared DEVPKEY_DeviceContainer_IsSharedDevice - Whether the device is shared.
System.Devices.IsNetworkConnected DEVPKEY_DeviceContainer_IsNetworkDevice - Whether the device is network connected.
System.Devices.IsDefault DEVPKEY_DeviceContainer_IsDefaultDevice - Whether the device is the default device.
System.Devices.Category DEVPKEY_DeviceContainer_Category_Desc_Singular - Device category (singular).
System.Devices.CategoryPlural DEVPKEY_DeviceContainer_Category_Desc_Singular - Device category (plural).
System.Devices.CategoryGroup DEVPKEY_DeviceContainer_CategoryGroup_Desc - Device category group.
System.Devices.FriendlyName DEVPKEY_DeviceContainer_FriendlyName - The friendly name.
System.Devices.Manufacturer DEVPKEY_DeviceContainer_Manufacturer - The manufacturer name.
System.Devices.ModelName DEVPKEY_DeviceContainer_ModelName - The model name.
System.Devices.ModelNumber DEVPKEY_DeviceContainer_ModelNumber - The model number.

 

Specifying properties that don't have a canonical name

When a property doesn't have a canonical name specified, it can still be retrieved by specifying the key as a string of the form "{Guid} pid". For example, System.Devices.ContainerId can be specified as "{8C7ED206-3F8A-4827-B3AB-AE9E1FAEFC6C} 2".

Concepts

System-Defined Device Properties

Unified Device Property Model