如何快速获得硬件ID在C#中? [英] How to fast get Hardware-ID in C#?

查看:198
本文介绍了如何快速获得硬件ID在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的计划,以配合一个许可证的硬件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.

这篇关于如何快速获得硬件ID在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆