3

I need to get a unique id of video card adapter. When searching in the properties of the device (using Device Manager of Windows), I notice that there is a property named Hardware Ids as shown in image bellow.

Hardware Ids of video card adapter

I tried to get these Ids in my winform application. I found this method:

string VideoCardInfoID()
{
  ManagementObjectSearcher objvide = new ManagementObjectSearcher("select * from Win32_VideoController");
  string output = string.Empty;
  foreach (ManagementObject obj in objvide.Get())
  {
    output += (obj["PNPDeviceID"] + "\n");             
  }
  return output;
}

The output of this code is:

PCI\VEN_10DE&DEV_1055&SUBSYS_908A104D&REV_A1\4&F7451F8&0&0008

I have two questions:

  1. Is PNPDeviceID of video card adapter unique across all machines? does it change when new fresh Windows installed? I know there some similar questions in stack overflow, but they does not contain a clear answers, such as this question and this question.

  2. Why there is additional characters in the output of the c# function (\4&F7451F8&0&0008)?

Update: I try install new fresh Windows and the Hardware Ids and PNPDeviceID still the same, But I still don't know if PNPDeviceID unique across all machines (I mean the same as MAC address).

asynts
  • 2,213
  • 2
  • 21
  • 35
Ahmed Shamel
  • 1,982
  • 3
  • 24
  • 58
  • 2
    If you have the exact same adapter make and model installed twice on the machine then they'll have the exact same hardware id. The [Hardware ID](https://learn.microsoft.com/en-us/windows-hardware/drivers/install/hardware-ids) is used by the OS to activate the proper driver. The extra stuff after the hardware id makes it unique, it is the [Instance ID](https://learn.microsoft.com/en-us/windows-hardware/drivers/install/instance-ids). The entire string, hardware+instance id, is the "Device Instance ID". – Hans Passant Aug 18 '18 at 13:17
  • @HansPassant What I understand from your comment is that the `Hardware ID` is not unique ID, two video adapters may have the same `Hardware ID`. Windows adds additional string to the Hardware ID to make it unique ID. Please correct me if I wrong. – Ahmed Shamel Aug 18 '18 at 14:07
  • You could perform a cross check in `Win32_PnPEntity` using the preferred reference (Name could be one) and extract the "Hardware ID", which, IIRC, is a combination of Vendor ID, Hardware Revision, serial number etc. in a comma separated list of references. The Instance ID should be appended to PNPDeviceID or DeviceID. (Can't verify right now, give it a look). – Jimi Aug 18 '18 at 16:52
  • @Jimi Thanks for answer, but the important question (Is PNPDeviceID of video card adapter unique?) still not answered. – Ahmed Shamel Aug 18 '18 at 17:15
  • I don't think I've ever heard of an "Across-All-Machines" requirement for a PnpDeviceId. The combination of IDs + the Instance ID (which is also applied to the `Rev_N`, the revision number) is used to uniquely identify a piece of hardware on a single machine. The Wmi classes always associate a HardwareId with a SystemName, the name of the machine the query refers to. These Ids come from the Manufactures. Are they *Unique* across borders? N/A. Ask Hans Passant; if he doesn't know, your next stop is the NVidia HQ. If they know it and have a unique answer to this. – Jimi Aug 18 '18 at 17:33
  • @HansPassant can you help me? – Ahmed Shamel Aug 20 '18 at 10:32

1 Answers1

3

Is PNPDeviceID of video card adapter unique across all machines?

No. Essentially what this string is comprised of is

<Bus>\<Device ID>\<Instance ID>

The Instance ID is only unique within the context of the current system, and it may not even be unique for the whole system, only for the device's bus.

That is, if you have two identical video cards installed in the computer, they will have the same Device ID, but different Instance ID.

A graphics card driver might use its own serial number in the Instance ID. So it is possible that Instance ID is globally unique, but WMI cannot make that guarantee for all PNP devices.

At this point you will likely have to use a per-vendor documented way to determine the device's serial number, if at all possible.

vcsjones
  • 138,677
  • 31
  • 291
  • 286
  • @Ahmed Shamel This is the answer you're looking for. Don't be greedy, mark the answer and give out the bounty... – Joshua VdM Aug 29 '18 at 16:57