Muokkaa

Jaa


Hardware ID

A hardware ID is a vendor-defined identification string that Windows uses to match a device to a driver package. A hardware ID identifies a device and indicates that any driver package that declares it can work with a device that has that ID for some degree of functionality. In most cases, a device has more than one hardware ID associated with it. Typically, a list of hardware IDs is sorted from most to least suitable for a device. For example, the list of conceptual hardware IDs for a device might look like:

<Product X made by company Y with firmware revision Z>
<Product X made by company Y that is a device of type W>

Where the actual hardware IDs would represent those concepts using strings that follow the format requirements of a hardware ID.

Creating a hardware ID for a device

Hardware IDs are reported to the Plug and Play Manager (PnP) by a device's enumerator (its bus driver). Typically, when the author of a bus driver needs to create a new hardware ID for a device it reports to PnP, it uses one of the following generic formats:

<enumerator>\<enumerator-specific-device-ID>

This format is the most common for individual PnP devices reported to the Plug and Play (PnP) manager by a single enumerator.

\*<generic-device-ID>

The asterisk indicates that more than one enumerator supports the device, such as ISAPNP and the BIOS.

<device-class-specific-ID>

For more information, see Generic Identifiers.

An existing device class with its own established naming convention might use a custom format. For information about their hardware ID formats, see the hardware specification for such buses.

The number of characters of a hardware ID, excluding a NULL terminator, must be less than MAX_DEVICE_ID_LEN. This constraint applies to the sum of the lengths of all the fields and any \\ field separators in a hardware ID. For more information, see the Operations section of IRP_MN_QUERY_ID.

Hardware IDs for root enumerated devices

Root enumerated devices are special in that they can be created using APIs where a hardware ID can be provided. Root enumerated devices with hardware IDs sharing generic namespaces such as ROOT\SYSTEM might conflict and result in a yellow-bang error icon in Device Manager when updating Windows.

You can prevent this error by using a unique namespace for each driver that has a root enumerated device. For a USB or system device, instead of using ROOT\USB or ROOT\SYSTEM" use ROOT\[COMPANYNAME]\[DEVICENAME]. Then, before installing, check to see if the devnode is already present.

Obtaining the list of hardware IDs for a device

To find the list of hardware IDs for a given device, follow these steps:

  1. Open Device Manager.
  2. Find the device in the tree.
  3. Right-select the device and select Properties.
  4. Select the Details tab.
  5. In the Property drop-down, select Hardware Ids or Compatible Ids.

The list of hardware IDs can also be obtained programmatically by retrieving the DEVPKEY_Device_HardwareIds property on a device. For example, that property can be retrieved with APIs such as IoGetDevicePropertyData, SetupDiGetDeviceProperty, or CM_Get_DevNode_Property.

The list of hardware IDs that this routine retrieves is a REG_MULTI_SZ value. The maximum number of characters in a hardware list, including a NULL terminator after each hardware ID and a final NULL terminator, is REGSTR_VAL_MAX_HCID_LEN. The maximum possible number of IDs in a list of hardware IDs is 64.

Examples of Hardware IDs

Here's an example of a generic identifier for a PnP device:

root\*PNP0F08

Here's an example of an identifier for a PCI device:

PCI\VEN_1000&DEV_0001&SUBSYS_00000000&REV_02