tags:

views:

1718

answers:

4

hi..

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;
        }
+1  A: 

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.

casperOne
so what should i do?? which unique thing i can get from system?
Mohsan
A: 

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.

Brian R. Bondy
A: 

We use the main drive's serial number (using GetVolumeInformation).

The other option is MAC address (but it gets tricky if there's more than one network connection, no network connection, etc).

Blorgbeard
Unfortunately that doesn't return the serial number, it returns the volume ID which can be changed at any time.
Paul Alexander
+1  A: 

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