tags:

views:

987

answers:

4

How to uniquely identify computer (mainboard) using C#(.Net/Mono, local application)?

Edition. We can identify mainboard in .Net using something like this (see Get Unique System Identifiers in C#):

using System.Management;
...
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_MotherboardDevice");
...

But unfortunately Mono does not support System.Management. How to do it under Mono for Linux? - I don't know :(

+2  A: 

Try this:

http://carso-owen.blogspot.com/2007/02/how-to-get-my-motherboard-serial-number.html

Personally though, I'd go with hard drive serial number. If a mainboard dies and is replaced, that PC isn't valid any more. If the HDD drive is replaced, it doesn't matter too much because the software was on it.

Of course, on the other hand, if the HDD is just moved elsewhere, the information goes with it, so you might want to look at a combination of serial numbers, depending what you want it for.

Neil Barnwell
Both my mainboards and my operating systems tend to outlive my harddrives. At least so far. There are things called "backups" which enable an OS + software to survive dying HDDs :-)
Joey
To me the most unique thing that define a computer is the HDD. You take the hdd to another mainboard. Do you think your computer is the empty/with a new hdd mainboard or the one that has all your data, your OS etc. ?
Clement Herreman
+3  A: 

Please see: Get Unique System Identifiers in C#

Mitch Wheat
+4  A: 

Write a function that takes a few unique hardware parameters as input and generates a hash out of them.

For example, Windows activation looks at the following hardware characteristics:

  • Display Adapter
  • SCSI Adapter
  • IDE Adapter (effectively the motherboard)
  • Network Adapter (NIC) and its MAC Address
  • RAM Amount Range (i.e., 0-64mb, 64-128mb, etc.)
  • Processor Type
  • Processor Serial Number
  • Hard Drive Device
  • Hard Drive Volume Serial Number (VSN)
  • CD-ROM / CD-RW / DVD-ROM

You can pick up a few of them to generate your unique computer identifier.

Developer Art
On the other hand you might want to keep them separate. That would allow for example to put in more memory, and you can allow changes as long as they happen one at a time.
Guffa
+1  A: 

How about the MAC address of the network card?

kenny
Maybe you are right. Simple common method for Windows and Linux using Mono is obtaining MAC address of the network card(s).
macropas