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;
4

5 回答 5

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.

于 2013-05-10T04:42:23.187 回答
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...

于 2013-03-30T23:06:45.447 回答
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.

于 2013-03-31T04:32:45.393 回答
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;
    }
于 2015-05-15T06:11:36.037 回答
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.

于 2013-03-31T01:22:09.853 回答