0

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.

Community
  • 1
  • 1
Shinichi
  • 475
  • 4
  • 7
  • 25
  • Are you talking about a UUID/GUID? Give us an example of what you're referring to. – Matt Ball Apr 21 '12 at 15:48
  • 1
    Are you looking for [Guid.NewGuid](http://msdn.microsoft.com/en-us/library/system.guid.newguid.aspx)? – Filburt Apr 21 '12 at 15:54
  • I think GUID is not. I want every time call function that will return 1 unique ID on 1 PC like TeamViewer. I want use that like a hardware ID for license management. – Shinichi Apr 21 '12 at 23:53

1 Answers1

3

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.

ABH
  • 3,391
  • 23
  • 26
  • I think GUID is not. I want every time call function that will return 1 unique ID on 1 PC like TeamViewer. I want use that like a hardware ID for license management. – Shinichi Apr 21 '12 at 23:53
  • @Shinichi Just updated my answer, please have a look. – ABH Apr 22 '12 at 19:22