Unique Machine ID

Hi,

I have been looking at the code for the Shareware kit and there is some code that creates a ClientID from the processer ID. The code is:

try

{

string cpuInfo = String.Empty;

ManagementClass mc = new ManagementClass("Win32_Processor");

ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)

{

if (cpuInfo == String.Empty)

{ // only return cpuInfo from first CPU

cpuInfo = mo.Properties["ProcessorId"].Value.ToString();

}

}

return cpuInfo;

}

catch(Exception ex)

{

throw new DataStoreUniqueMachineIDException(

"Error while calculating the unique machine ID.", ex);

}

My question is: How dependable would this be using it for Licensing an application so that the app could only run the machine with the same cpuInfo value. Anyone know of any problems with doing this

thanks

-Barb



Answer this question

Unique Machine ID

  • Harini

    Never trust one ID, you can combine the CPU ID, MAC Address and HDD Serial number for example to one hash.


  • GAINSCOM

    I have been doing other inquires about this and have been informed that testing done on a few dozen computers led to several returning the same results for processor id - so I guess the answer is that it has a fairly low probability that it may be the same for 2 different computers. I did not get any answer about the second point but I am going to assume it to be true.
  • Dare Obasanjo - MSFT

    You should store the value in the register or filesystem, encryped. So the user can't change it and everytime you start your application you read that value and compare it to the current CPU hash, if it equals go on; otherwise, inform the user and quit.


  • Jacky Chau

    I already know how I am going to store and use the value, I was just wondering about:

     

     1) its uniqueness

     2) and it's one-to-one correspondence ie:  the procedure will always return a value and this value will not be different on subsequent calls to the procedure

     

    thanks

     

    -Barb


  • Federico Provera

    I hate to answer this question with another question...

    When will cpuinfo be obtained Will it be in a build Will it be on install Will it be on runtime Where are you going to be storing this CpuInfo




  • Srikanth Bogadapati

    cpuinfo starts off empty,

    it then gets the collection of management objects from the system

    then it runs through the for loop looking for a non-empty string for the ProcessorId index

    this is what it will return, this value is inside of at least one of the instances of management object or so I am lead to believe by the code -

    now this is code directly from the Shareware Starter kit and it seems to work just fine for me. I was just wondering about my original questions.


  • Nagarajan

    Visual Studio offers the tool to do simplify this process.

    Activate the Server Explorer panel, then:

    Servers -> [your computer] -> Processors -> [first processor]

    Drag'n'drop this to your Form or User Control.

    Then it's just:

    string id = processor1.ProcessorId;


  • Unique Machine ID