How to fast get Hardware-ID in C#?

guaike picture guaike · Feb 25, 2010 · Viewed 101.1k times · Source

I need in my program to tie a license to a hardware ID. I tried use WMI, but it still slow.

I need, for example, CPU, HDD, and motherboard info.

Answer

HotTester picture HotTester · Feb 25, 2010

For more details refer to this link

The following code will give you CPU ID:

namespace required System.Management

var mbs = new ManagementObjectSearcher("Select ProcessorId From Win32_processor");
ManagementObjectCollection mbsList = mbs.Get();
string id = "";
foreach (ManagementObject mo in mbsList)
{
    id = mo["ProcessorId"].ToString();
    break;
}

For Hard disk ID and motherboard id details refer this-link

To speed up this procedure, make sure you don't use SELECT *, but only select what you really need. Use SELECT * only during development when you try to find out what you need to use, because then the query will take much longer to complete.