使用C CPU ID ++ - 窗户 [英] CPU ID using C++ - windows

查看:114
本文介绍了使用C CPU ID ++ - 窗户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要得到我的电脑使用C(视窗)++的CPU ID。

I want to get CPU Id of my computer (windows) using c++.

我用这个code 来得到它。

它输出的信息是这样的:

It outputs information something like:

For InfoType 0
CPUInfo[0] = 0x5
CPUInfo[1] = 0x756e6547
CPUInfo[2] = 0x6c65746e
CPUInfo[3] = 0x49656e69

For InfoType 1
CPUInfo[0] = 0xf31
CPUInfo[1] = 0x20800
CPUInfo[2] = 0x41d
CPUInfo[3] = 0xbfebfbff

For InfoType 2
CPUInfo[0] = 0x605b5001
CPUInfo[1] = 0x0
CPUInfo[2] = 0x0
CPUInfo[3] = 0x7c7040

For InfoType 3
CPUInfo[0] = 0x0
CPUInfo[1] = 0x0
CPUInfo[2] = 0x0
CPUInfo[3] = 0x0

For InfoType 4
CPUInfo[0] = 0x0
CPUInfo[1] = 0x0
CPUInfo[2] = 0x0
CPUInfo[3] = 0x0

For InfoType 5
CPUInfo[0] = 0x40
CPUInfo[1] = 0x40
CPUInfo[2] = 0x0
CPUInfo[3] = 0x0

For InfoType 80000000
CPUInfo[0] = 0x80000008
CPUInfo[1] = 0x0
CPUInfo[2] = 0x0
CPUInfo[3] = 0x0

For InfoType 80000001
CPUInfo[0] = 0x0
CPUInfo[1] = 0x0
CPUInfo[2] = 0x0
CPUInfo[3] = 0x0

For InfoType 80000002
CPUInfo[0] = 0x20202020
CPUInfo[1] = 0x20202020
CPUInfo[2] = 0x20202020
CPUInfo[3] = 0x20202020

For InfoType 80000003
CPUInfo[0] = 0x47202020
CPUInfo[1] = 0x69756e65
CPUInfo[2] = 0x4920656e
CPUInfo[3] = 0x6c65746e

For InfoType 80000004
CPUInfo[0] = 0x20295228
CPUInfo[1] = 0x20555043
CPUInfo[2] = 0x30382e32
CPUInfo[3] = 0x7a4847

For InfoType 80000005
CPUInfo[0] = 0x0
CPUInfo[1] = 0x0
CPUInfo[2] = 0x0
CPUInfo[3] = 0x0

For InfoType 80000006
CPUInfo[0] = 0x0
CPUInfo[1] = 0x0
CPUInfo[2] = 0x4008040
CPUInfo[3] = 0x0

For InfoType 80000007
CPUInfo[0] = 0x0
CPUInfo[1] = 0x0
CPUInfo[2] = 0x0
CPUInfo[3] = 0x0

For InfoType 80000008
CPUInfo[0] = 0x2028
CPUInfo[1] = 0x0
CPUInfo[2] = 0x0
CPUInfo[3] = 0x0

我不能这是我的电脑独有的CPU ID的信息中了解。

I could not understand among those information which is my computer's unique CPU Id.

谁能好心帮我在此。

推荐答案

你的意思是序列号,谁做的处理器,或者字符串标识品牌和处理器的模式。

Do you mean "serial number", "who made the processor", or the "string that identifies the make and model of the processor".

编号:

除非你有一个奔腾III,你没有一个唯一ID与CPU有关。

Unless you have a Pentium III, you do not have a "unique ID" associated with your CPU.

英特尔推出与P3处的唯一的ID(序号)的指令。但在隐私巨大的轩然大波后,他们很快就在随后的CPU版本中禁用该功能。

Intel introduced the unique id (serial number) instruction with the P3. But after a huge uproar over privacy, they quickly disabled that feature in subsequent CPU releases.

有关的记录,在装配执行此功能的指令:

For the record, the instruction that executed this feature in assembly:

mov eax, 3
cpuid

的处理器序号为eax中的串联,EDX,和ECX一起

The processor serial number was the concatenation of eax, edx, and ecx together

您可以通过传递3作为第二个参数实现与__cpuid功能同样的事情。但是,这不工作或者返回序列号,除非你有一个P3。

You can achieve the same thing with __cpuid function by passing "3" as the second parameter. But it won't work or return a serial number unless you have a P3.

卖方(谁提出的处理器)

int regs[4] = {0};
char vendor[13];
__cpuid(regs, 0);              // mov eax,0; cpuid
memcpy(vendor, &regs[1], 4);   // copy EBX
memcpy(vendor+4, &regs[2], 4); // copy ECX
memcpy(vendor+8, &regs[3], 4); // copy EDX
vendor[12] = '\0';
print("My CPU is a %s\n", vendor);

在你的情况,这应打印GenuineIntel。

In your case, this should print "GenuineIntel".

品牌和型号(BRAND字符串)

如果你想CPUID指令的所有细节,包括如何获得品牌,型号和CPU的步进,以及品牌字符串,如英特尔(R)酷睿(TM)i7处理器-3770 CPU @ 3.4GHz的......你可以在下面的链接引用英特尔手册。向下滚动文件找到CPUID的文档。我懒得打字起来给你。

If you want all the details of the CPUID instruction, including on how to get the make, model, and stepping of your CPU, as well as the "Brand String" such as "Intel(R) Core (TM)i7-3770 CPU @ 3.4GHZ...." you can reference the Intel manual at the link below. Scroll down the document to find the docs for CPUID. I'm too lazy to type it up for you.

<一个href=\"http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-2a-manual.pdf\" rel=\"nofollow\">http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-2a-manual.pdf

在调用CPUID指令之前,由MSVC编译器地图信息类型,以EAX提供的__cpuid()指令。此后指令返回,EAX,EBX,ECX和EDX被复制到你传递给这个函数的CPUInfo [4]数组。

The __cpuid() instruction provided by the MSVC compiler maps "InfoType" to EAX before the call to the cpuid instruction. After that instruction returns, EAX, EBX, ECX, and EDX get copied to the CPUInfo[4] array you passed into this function.

这篇关于使用C CPU ID ++ - 窗户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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