现在网上不少教程,教人通过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. 第1章 Java中常用字符串方法总结

    1.1 charAt方法——提取指定字符 1.2 codePointAt方法——提取索引字符代码点 1.3 codePointBefore方法——获取索引前一个字符的代码点 1.4 codePoint ...

  2. MapReduce形象总结

    We want to count all to the books in the library.You count up shelf #1,I count up shelf #2. That's a ...

  3. Redis系列(一)——简介及安装

    摘自:redis中文网(http://www.redis.net.cn/) 参考:http://www.cnblogs.com/hoojo/p/4466024.html,http://keenwon. ...

  4. Example to use django queryset

    from django.db.models import get_app, get_models, get_model from django.db import models #get the ce ...

  5. Oracle PLSQL

    Oracle :show explain plan select * from table(dbms_xplan.display); EXPLAIN PLAN FOR statements In fa ...

  6. 探索 OpenStack 之(14):OpenStack 中 RabbitMQ 的使用

    本文是 OpenStack 中的 RabbitMQ 使用研究 两部分中的第一部分,将介绍 RabbitMQ 的基本概念,即 RabbitMQ 是什么.第二部分将介绍其在 OpenStack 中的使用. ...

  7. sudo: unable to resolve host xxx解决办法

    问题: root@wiki:~# sudo lsb_release -a sudo: unable to resolve host wiki No LSB modules are available. ...

  8. UVALive 6257 Chemist's vows --一道题的三种解法(模拟,DFS,DP)

    题意:给一个元素周期表的元素符号(114种),再给一个串,问这个串能否有这些元素符号组成(全为小写). 解法1:动态规划 定义:dp[i]表示到 i 这个字符为止,能否有元素周期表里的符号构成. 则有 ...

  9. a 标签中调用js的几种方法

    我们常用的在a标签中有点击事件: 1. a href="javascript:js_method();" 这是我们平台上常用的方法,但是这种方法在传递this等参数的时候很容易出问 ...

  10. 链表面试题Java实现【重要】

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