17

I want to use some thing unique for a licensing system. i decided to use ProcessorID from Win32_Processor Management class.

I tried on two different systems with same processor type..

It shows me same processorID for both system. i am using this code

public static String GetCPUId()
{
    String processorID = "";

    ManagementObjectSearcher searcher = new ManagementObjectSearcher(
        "Select * FROM WIN32_Processor");

    ManagementObjectCollection mObject = searcher.Get();

    foreach (ManagementObject obj in mObject)
    {
        processorID = obj["ProcessorId"].ToString();
    }

    return processorID;
}
casperOne
  • 73,706
  • 19
  • 184
  • 253
Mohsan
  • 2,483
  • 6
  • 47
  • 62
  • 1
    I have same problem, but looks like there is no answer for this. After so many years, did you found the answer? – qakmak Apr 25 '15 at 15:03

4 Answers4

19

No, it can't be guaranteed that it will be unique, as the processor might not even support the CPUID instruction, in which case, the call can't be guaranteed to succeed.

Also, you are neglecting that a machine might have multiple processors in it, so getting the id of a single processor doesn't help.


As others have indicated, if you want to get a unique id for the system, your best bet is to create an id which is an amalgam of various component ids on the system.

A hash (and not just any, but one that has very few collisions) of various values of the hardware could suffice. You'd probably want to use things that are fairly embedded in the system, such as the processor, motherboard info, but not things easily detached/changed, such as USB drives/hubs/etc.

casperOne
  • 73,706
  • 19
  • 184
  • 253
10

Most licensing systems rely on multiple hardware components to create a fingerprint. No single component is used as the only unique key. So you might take the following into consideration:

  • MAC Addresses of all network adapters (Can get tricky if they have a docking station or enable/disable their wireless on a laptop)
  • CPUID
  • Motherboard component part numbers (like the IDE or SCSI controllers)
  • Serial number of system drive (NOT Volume ID which is easy to change)
  • etc.

When combined as a whole you'll get a unique representation of the machine. The danger of course comes when the user changes something on their machine. Do they lose their license? Do they have to contact you?

Also note that WMI classes often require admin rights to read the kind of information that you're looking for which would be a real hassle for Vista & Windows 7 users.

Doing hardware locking is very difficult to get right. So I'd recommend either 1. don't do it or 2. purchase a commercial library that already does this.

Paul Alexander
  • 31,970
  • 14
  • 96
  • 151
  • We used a combination of CPUID and MAC Address for generating unique id but unfortunately later we found out that there are three computers in our office which are generating the same id :( – Sajib Mahmood Feb 28 '12 at 11:46
  • 1
    ya, before seeing the incident happening in front of my very eyes I also thought that it is impossible to happen but it really did happen. – Sajib Mahmood Feb 28 '12 at 17:45
  • It's more likely a bug in the software that generates the code than not only two, but three cards in the same office having the same MAC address. If that were the case you'd have regular network issues with those machines. – Paul Alexander Feb 28 '12 at 18:59
  • 4
    @Paul Alexander: I also knew that MAC addresses are unique as I was studied in my network courses.But do you know in windows, MAC address could be changed.Just make a little search on it.You'll get a lot of resources to change MAC.After the search please tell me is it unique or not. – Abdur Rahman Feb 29 '12 at 05:59
  • 2
    Yep you can configure a MAC address - and your code can detect that. If you allow spoofed MAC addresses into your licensing fingerprint - that's a bug in the code. – Paul Alexander Feb 29 '12 at 23:05
  • 1
    @PaulAlexander Duplicate MAC addresses become more common when virtual machines enter the equation, since they don't have uniquely assigned MAC addresses. – reirab Dec 17 '15 at 20:55
7

The ProcessorID or CPUID are for identifying the model and feature set of the processor (ARM, x86/x64).

The Pentium III supported a Processor Serial Number (PSN). In addition to only being supported on the Pentium III (and Transmeta's Efficeon and Crusoe processors), the feature had to be enabled in BIOS and raised privacy concerns.

So no, ProcessorID is not unique for all computers. Additionally, it is very likely to not be unique across computers in your company (since many organizations buy multiple computers of the same model).

Note: the ATPO is unique to each CPU, but it is physically printed on the chip.

Trisped
  • 5,705
  • 2
  • 45
  • 58
1

For the unique string you're looking for, we use the MAC address. If the user doesn't have a MAC address we simply allow multiple installs. It covers most cases which is all we wanted to accomplish.

Community
  • 1
  • 1
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
  • @jyz That depends on how unique you want the IDs to be. A little bit of piracy of your software may be acceptable if it keeps your paying users from experiencing service interruptions. – wooobie May 03 '17 at 18:46