我需要在我的计划,以配合一个许可证的硬件ID。我尝试使用WMI,但它仍然缓慢。
I need in my program to tie a license to a hardware ID. I tried use WMI, but it still slow.
我需要的,例如,CPU,硬盘,和主板信息。
I need, for example, CPU, HDD, and motherboard info.
有关更多详情,请参阅的这个链接
For more details refer to this link
下面code会给你的CPU ID:
The following code will give you CPU ID:
所需的命名空间 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;
}
有关硬盘ID和主板ID详见的这个链接
For Hard disk ID and motherboard id details refer this-link
要加快这一过程,请确保您不使用 SELECT *
,但只选择你真正需要的。使用 SELECT *
只有当你试图找出你需要使用的,因为那么查询将采取的在开发过程中多的时间才能完成。
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.