3

I'm looking to produce a unique ID for some embedded systems I manage. The systems are running Windows Embedded 7 Standard and .NET 4.0. The IDs must:

  • Be relatively unique -- each embedded system is running on the same motherboard, drive, etc. and I can't have collisions.
  • Persist across reinstalls -- these computers get reimaged with new versions of our software regularly.
  • Cannot rely on the disk serial number -- we're not using real disks, but rather CF cards with a CF to SATA adapter, and the CF cards are swapped out occasionally.

Also, I have multiple NICs in the machine, so relying on the on-board NIC MAC address will work only if someone can tell me how to identify which NIC is on-board vs a USB device. After further research it looks like this isn't possible within the scope of managed code.

What's the best way to accomplish this?

David Pfeffer
  • 38,869
  • 30
  • 127
  • 202

1 Answers1

2

I suggest you use WMI to obtain information about the machine's CPU, using the Win32_Processor class. Then you can construct a unique id for the machine from attributes such as ProcessorId and UniqueId.

This way you would be using each machine's CPU itself as the persisten "store" for the machine id.

CesarGon
  • 15,099
  • 6
  • 57
  • 85
  • According to http://stackoverflow.com/questions/1101772/win32-processoris-processorid-unique-for-all-computers, the `ProcessorId` isn't unique across all PCs. – David Pfeffer Oct 07 '10 at 13:13
  • That's why you need to combine it with UniqueId. Basically, ProcessorId gives you the CPU's model or feature set, and UniqueId is unique within a given model or feature set. A combination of both is apparently guaranteed to be unique across machines. – CesarGon Oct 07 '10 at 13:14
  • 1
    UniqueId comes back as null on every system I've tested. According to some Googling, it seems to only be implemented on Pentium III. – David Pfeffer Nov 16 '10 at 13:23
  • Well, if it doesn't work, I think that you shouldn't accept this as an answer. It's only fair. – CesarGon Dec 07 '10 at 14:02