Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fast get Hardware-ID in C#?

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.

like image 336
guaike Avatar asked Feb 25 '10 10:02

guaike


1 Answers

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.

like image 128
13 revs, 3 users 89% Avatar answered Sep 19 '22 14:09

13 revs, 3 users 89%