1

Possible Duplicate:
Generating a unique machine id

I want processor serial number which is unique id no other processor have that id. Also i have hard disk serial number. I am using c++. Can anyone please help me for this?

I need unique machine id like CPU number,motherboard number using c++.

Win32_BaseBoard, Win32_Processor Win32_DiskPartition

Thank you.

Community
  • 1
  • 1
user1586515
  • 87
  • 3
  • 7
  • 1
    C++ has no notion of a processor serial number. If this is a question about some specific platform, you have to tell us what platform. Also note that processor IDs are not suitable for security or licensing purposes because (typically) all you can do is ask the OS what it thinks the serial number is, and you get whatever answer the OS is programmed to give you. – David Schwartz Aug 09 '12 at 04:29
  • 1
    This is problematic -- many CPUs don't provide a unique ID, and of course many computers have more than one CPU. What do you need a unique processor ID for? Perhaps there is another approach that will work better. – Jeremy Friesner Aug 09 '12 at 04:43
  • possible duplicate of [Generating a unique machine id](http://stackoverflow.com/questions/99880/generating-a-unique-machine-id). Also, http://stackoverflow.com/questions/3636115/uniquely-identify-pc-based-on-software-hardware – tenfour Aug 09 '12 at 09:39

3 Answers3

4

According to Wikipedia, starting with the Pentium III the CPUID assembler opcode is supported, however due to security concerns is no longer implemented. See the following article for details: http://en.wikipedia.org/wiki/CPUID#EAX.3D3:_Processor_Serial_Number

TheSteve
  • 1,138
  • 6
  • 12
2

The best way is to derive a Machine Unique ID from different sources rather than depending on single parameter.

Check http://sowkot.blogspot.com/2008/08/generating-unique-keyfinger-print-for.html for more information.

Even the method described in the above link can't guarantee always same MID (user might change the hardware).

Based on my experience, at the application start/launch generate MID and store in the application specific area (may be in registry) and use this for all other application related tasks instead of generating every time. In such case a normal GUID generation should suffice.

roalz
  • 2,699
  • 3
  • 25
  • 42
Praveen
  • 21
  • 1
1

If you need a unique ID, you don't have to tie it up to the hardware, simply, generate a new random ID (128 bits or larger)! Store it in whatever persistent storage mechanism you prefer, so that next time you extract the same ID you generated before.

If you use processor or disk serial numbers, they will be subject to change, because users could upgrade their hardware. Your own unique ID will never change. The only downside of this, is that machines with dual boot will have two or more ID's -- one ID per instance of the OS.

seva titov
  • 11,720
  • 2
  • 35
  • 54
  • This method is very easy to hack. I recommend using the MAC adress or the CPU id, like here https://oroboro.com/unique-machine-fingerprint/ – BaptisteB Oct 12 '16 at 07:39
  • @BaptisteB, As I mentioned in the answer, the methods of tying up your ID to MAC address of network card, or disk serial number of CPU id simply don't work. The reason is the user can swap network drive, or CPU, or disk drive, and now your app will be broken. Besides, it is just not very nice to impose a requirement on your users that they are prohibited from ever upgrading individual components in their machines. – seva titov Oct 12 '16 at 17:32
  • @BaptisteB, If your goal is that users won't be able to hack it, you should use [Trusted Platform Module](https://en.wikipedia.org/wiki/Trusted_Platform_Module), provided your computer has one. It was specifically designed to serve as an identity for your computer. Unlike replaceable parts like network cards and CPUs users are expected to ensure TPM module is not tampered with. In fact in all machines I know of, TPM is soldered into motherboard, so it is pretty hard to replace it. – seva titov Oct 12 '16 at 17:39