[ACCEPTED]-Get Unique System Identifiers in C#-system-identification

Accepted answer
Score: 10

Here's a good start with WMI ...

// Win32_CPU will work too
var search = new ManagementObjectSearcher( "SELECT * FROM Win32_baseboard" );
var mobos = search.Get();

foreach (var m in mobos)
  var serial = m["SerialNumber"]; // ProcessorID if you use Win32_CPU

You can do 2 that with many pieces of hardware and come 1 up with a solution.

Score: 8

You can use the System.Management namespace to get all stuff 3 related to the hardware, ProcessorId, MAC 2 addresses, and a lot more info you can then 1 hash together.

Take a look at this article:


Score: 6

Presuming you are talking about Windows, then 5 each Windows installation has a unique product 4 id (which you can see when you view the 3 properties of My Computer). I think this 2 is stored in HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion:ProductId(REG_SZ). I take it you want more than 1 that?

Score: 2

You can use WMI with C# to get quite a bit 5 of information about hardware.

Hard Disk 4 IDs and Ethernet MAC Address are two common 3 unique identifiers used in system identification 2 schemes. The MAC Address is, in theory, unique 1 per network card.

Score: 2

You could look into using GUID's

What is a GUID

For those of you 17 who don't know, a GUID (pronounced goo'id 16 - Globally unique identifier) is a 128-bit 15 integer that can be used to uniquely identify 14 something. You may store users or products 13 in your database and you want somehow uniquely 12 identify each row in the database. A common 11 approach is to create a autoincrementing 10 integer, another way would be to create 9 a GUID for your products.

How to create a GUID in C#

The GUID method 8 can be found in the System namespace. The 7 GUID method System.Guid.NewGuid() initializes 6 a new instance of the GUID class.

There are 5 also a few overloads available for those 4 of you who want the GUID formatted in a 3 particular fashion.

The following live sample 2 will output the GUID generated, the source 1 code is also below.

Response.Write(@"<br>System.Guid.NewGuid().ToString() = " + System.Guid.NewGuid().ToString());
Response.Write(@"<br>System.Guid.NewGuid().ToString(""N"") = " + System.Guid.NewGuid().ToString("N"));
Response.Write(@"<br>System.Guid.NewGuid().ToString(""D"") = " + System.Guid.NewGuid().ToString("D"));
Response.Write(@"<br>System.Guid.NewGuid().ToString(""B"") = " + System.Guid.NewGuid().ToString("B"));
Response.Write(@"<br>System.Guid.NewGuid().ToString(""P"") = " + System.Guid.NewGuid().ToString("P"));
Score: 2

Network card MAC address:

foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
    // probably need to do some filtering on ni.NetworkInterfaceType here


More Related questions