3

I am using the code below to get a unique CPU ID, i found various samples on the web using this. However. By chance I happen to own 2 Asus Laptops. One is a quad core i5 the other an heavy duty i7 octocore both are 64 bit machines.. To my big surprise they both produce the same "unique" CPU ID ???.

So this code isnt working for me, are there other methods to get unique CPU ids or do i do something wrong here. What I hope to get is a number that specific for each CPU that is made

string cpuID = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)
{
 if (cpuID == "")
 {
      //Remark gets only the first CPU ID
      cpuID = mo.Properties["processorID"].Value.ToString();

 }
}
return cpuID;
user613326
  • 2,140
  • 9
  • 34
  • 63
  • 2
    This has not been possible since Pentium III. They took out that feature for privacy reasons. – Mysticial Mar 30 '13 at 21:40
  • 1
    More information here: http://en.wikipedia.org/wiki/Pentium_III#Controversy_about_privacy_issues – Mysticial Mar 30 '13 at 21:45
  • https://stackoverflow.com/questions/2333149/how-to-fast-get-hardware-id-in-c look at answer by alex sutu. it uses lots of fallback to get cpuid . Also combines not just cpu but also cpu hdd mac etc to make it more reliable. – bh_earth0 May 30 '18 at 10:12

5 Answers5

2

Maybe the UUID property of the Win32_ComputerSystemProduct object will suit your needs. It is supposed to be unique per-motherboard, as long as the manufacturer configures it in the first place. It's not too common for the CPU to move around without the motherboard coming along for the ride, anyways.

deGoot
  • 996
  • 4
  • 11
1

try

ManagementClass managClass = new ManagementClass("win32_processor");
ManagementObjectCollection managCollec = managClass.GetInstances();

foreach (ManagementObject managObj in managCollec)
{
    cpuInfo = managObj.Properties["processorID"].Value.ToString();
    break;
}

working fine here...

DeMama
  • 1,134
  • 3
  • 13
  • 32
  • 1
    that's the same code i am using and it does not provide unique ID's I got two difrent Asus laptops that will result the same string with it. – user613326 Mar 30 '13 at 23:13
  • Weird, code is working for me, i have tested 4 pc's and each time i get an unique processorid ?.. – DeMama Mar 30 '13 at 23:19
  • 1
    Well i am amazed too perhaps not all manufacturers use this in the same way, my machines are both Asus, with a pentium i5 and an i7 used on another brand it gave me a different number dough. It just indicates to me that it isnt unique, perhaps its more like a general series number or brand number ?? i dont know – user613326 Mar 30 '13 at 23:24
  • 1
    Instead of using `cpuInfo = managObj.Properties["processorID"].Value.ToString();` you could try: `Revision = managObj.Properties["Revision"].Value.ToString();` gets a much more unique id – DeMama Mar 30 '13 at 23:26
  • @DeMama and when `managObj.Properties["Revision"]` is NULL? I have one case of that, it's a Core i3 Processor, I'm looking for another way to get the `Revision` in C# value but without WMI. – Alexsandro Jan 16 '18 at 14:15
1

Although there is a clear machine instruction to ask CPUID of a CPU, this is not guaranteed to return a unique ID, therefore it is virtually impossible to get a universal unique CPUID no matter which method you use. We examined the low level assembly routines and get the same id for two different AMD cpus.

Babak
  • 121
  • 2
1
    var mbs = new ManagementObjectSearcher("Select ProcessorID From Win32_processor");
    var mbsList = mbs.Get();

    foreach (ManagementObject mo in mbsList)
    {
        cpuid = mo["ProcessorID"].ToString();
        textBox1.Text=cpuid;
    }
BMaximus
  • 1,062
  • 1
  • 11
  • 19
0

I came to the conclusion that this is just not a good method to get unique ID's. So instead of this method, I wrote a much larger piece of code in which I requested much more hardware identifiers of the system to build an unique identifier.

Its way better as this method would even produce different numbers if I would run it on cloned hardware, or if hardware gets changed. There is a lot of WMI info around and I think that's the place where people should look for creating something unique and not use ProcessorID.

TheLegendaryCopyCoder
  • 1,658
  • 3
  • 25
  • 46
user613326
  • 2,140
  • 9
  • 34
  • 63
  • 3
    So what keys are you using to build your unique ID? I don't really want to have the ID changeing if i change a HDD or some other component like a GPU that is likely changed by most people. – Marv Nov 18 '16 at 15:03
  • Can you please share the code. I believe it is related to licensing and copyright protection – Sujoy Apr 30 '19 at 10:55
  • Can you share please this method, how you build up the unique id? – Attila Szász Sep 12 '19 at 07:02