Question

Possible Duplicate:
What’s a good way to uniquely identify a computer?

As the title above, someone know how to generate a unique id like TeamViewer for licensing purpose in C#.

I want to call a function that should return 1 unique ID for a PC every time like TeamViewer. I want to use that like a hardware ID for license management.

Was it helpful?

Solution

You can use Guid.NewGuid method

public static Guid NewGuid();

Every time you call this method a new Guid is generated.

Edit: Based on your comments

Windows Management Instrumentation (WMI) is the thing you can use. For instance you can use the following code to get BIOS id's of the system.

ManagementObjectSearcher searcher = new 
    ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM 
    Win32_BIOS"); 

foreach (ManagementObject wmi in searcher.Get())
{ 
    Console.WriteLine("BIOS Serial Number: " + 
        wmi.GetPropertyValue("SerialNumber").ToString()); 
} 

Similarly you can get other system information and work with it to generate a unique id of a system. Here is a good article on CodeProject from where you can take help. Please have a look.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top