现在网上不少教程,教人通过WMI - Win32_Processor - ProcessorId来获取CPU的“序列号”,典型代码如下:

        public static string GetCPUSerialNumber()
{
string cpuSerialNumber = string.Empty;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuSerialNumber = mo["ProcessorId"].ToString();
break;
}
mc.Dispose();
moc.Dispose();
return cpuSerialNumber;
}

实际上,获取到的值并不是CPU的编号或者序列号,也并不是唯一的,对此,微软在msdn上有相关说明:

msdn链接:http://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx

msdn上的原文是这样说的:

ProcessorId

Data type: string
Access type: Read-only

Processor information that describes the processor features. For an x86 class CPU, the field format depends on the processor support of the CPUID instruction. If the instruction is supported, the property contains 2 (two) DWORD formatted values. The first is an offset of 08h-0Bh, which is the EAX value that a CPUID instruction returns with input EAX set to 1. The second is an offset of 0Ch-0Fh, which is the EDX value that the instruction returns. Only the first two bytes of the property are significant and contain the contents of the DX register at CPU reset—all others are set to 0 (zero), and the contents are in DWORD format.

根据msdn的说明可以知道,如果CPU支持CPUID指令的话,这个ProcessorId的值是指:“在寄存器EAX为1的时候,执行CPUID指令,返回的EAX和EDX寄存器里的数据,包含的是CPU型号、支持的指令集等信息”。如果CPU不支持CPUID指令呢?msdn没说,估计应该是空吧。

所以,ProcessorId并不是CPU的编号或者序列号,只是CPU的型号,指令集等信息。

参考链接:

[1]. Win32_Processor class

[2]. An attempt to bring CPUID to C#

通过WMI - Win32_Processor - ProcessorId获取到的并不是CPU的序列号,也并不唯一的更多相关文章

  1. C#获取电脑硬件信息(CPU ID、主板ID、硬盘ID、BIOS编号)

    最近学习过程中,想到提取系统硬件信息做一些验证,故而对网上提到的利用.NET System.Management类获取硬件信息做了进一步的学习.验证.验证是分别在4台电脑,XP SP3系统中进行,特将 ...

  2. 如何获取多核、多cpu系统中指定cpu的序列号

    如何获取多核.多cpu系统中指定cpu的序列号作者:SkyJacker(转贴请保持完整并注明作者和出处)http://www.cnpack.orgCnPack IV  QQ Group: 130970 ...

  3. Java获取Linux和Window系统CPU、内存和磁盘总使用率的情况

    这是一个工具类,获取的内容: CPU使用率:得到的是当前CPU的使用情况,这是算出的是两次500毫秒时间差的CPU使用率 内存使用率:[1 -  剩余的物理内存/(总的物理内存+虚拟内存) ] * 1 ...

  4. 获取可用的处理器(CPU)核数【转】

    linux下获取cpu核数,sysconf(_SC_NPROCESSORS_CONF),,, from:红黑联盟,https://www.2cto.com/kf/201210/164480.html ...

  5. C++通用WMI接口实现获取Windows操作系统内核版本号

    作为一名Windows开发者,能熟练掌握WMI技术,在开发Windows应用程序的时候往往能够事半功倍.今天来给大家分享一个使用WMI来获取Windows操作系统内核版本号的例子. 首先我们打开WMI ...

  6. C++调用WMI类查询获取操作系统名

    #define _WIN32_DCOM #include <iostream> #include <comdef.h> #include <Wbemidl.h> u ...

  7. 转:C# 获取磁盘及CPU的序列号

    原文地址:http://www.cnblogs.com/stray521/archive/2010/08/06/1793647.html //获取磁盘序列号 try { System.Manageme ...

  8. 浅谈如何获取机器的memory和CPU信息

    最近做了一个项目,需要获取机器的CPU和memory的使用情况.花了一些时间网上搜索了一下,自己也做了些测试.总结下来,基本上2种方式:一种是用WMI(2种),另一种是用Performance cou ...

  9. VC++ 获取Windows系统版本号、CPU名称

    转载:https://blog.csdn.net/sunflover454/article/details/51525179 转载:https://blog.csdn.net/magictong/ar ...

随机推荐

  1. 如何定制你自己的jQuery

    jQuery随着版本的不断升级代码量也随之增加,从1.0.0的不到两千行到现在的1.10.2已经突破1万行. 新的API不断增加,但有些在项目中并没有用到.jQuery团队很早就考虑到这一点,按模块来 ...

  2. git报错 error: cannot stat ‘'web/js': Permission denied

    切换分支时报错: error: cannot stat ‘'web/js': Permission denied 解决方法:退出编辑器.浏览器.资源管理器等,然后再切换就可以了.

  3. Hive drop table batched

    if the hive version not support drop table tablename purge. your drop table command will move data t ...

  4. 基于Retrotfit2.1+Material Design+ijkplayer开发的一个APP(新闻,gif 动图,视频播放)

    此项目主要目的还是为了练习框架的使用,仅供学习用途. 数据来源 新闻 直接用的聚合数据提供的接口:https://www.juhe.cn/docs/api/id/235gif动图 通过jsoup爬的某 ...

  5. Adaboost 卡口车辆检测训练

    之前做了SVM的车脸检测,主要是针对车脸,接下来尝试利用Adaboost和Haar进行车脸的检测.我利用的主要是opencv中的cascade,其已经把Adaboost相关的算法做成了exe,直接调用 ...

  6. 边工作边刷题:70天一遍leetcode: day 86-2

    Best Meeting Point 要点: 题本身不难理解,manhattan distance.follow up就变成weighted了(因为一个地方可以有多个住户) 注意input是grid的 ...

  7. UVALive 6656 Watching the Kangaroo --二分

    题意:给你一些区间,再查询一些点,问这些点与所有区间形成的最小距离的最大值.最小距离定义为:如果点在区间内,那么最小距离为0,否则为min(pos-L[i],R[i]-pos). 解法:当然要排个序, ...

  8. 2016百度之星-初赛(Astar Round2A)AII X

    Problem Description F(x,m) 代表一个全是由数字x组成的m位数字.请计算,以下式子是否成立: F(x,m) mod k ≡ c Input 第一行一个整数T,表示T组数据. 每 ...

  9. Android多线程----异步消息处理机制之Handler详解

    ​[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/ ...

  10. android机型排行榜(201509)

    http://forum.techweb.com.cn/thread-1352272-1-1.html