如何获取处理器和主板 ID?
我使用了 http://www.rgagnon.com/javadetails/java-0580 中的代码.html 获取主板Id,但结果为“null”。
怎么可能?
我还对代码进行了一些修改,使其看起来像这样来获取 ProcessorId:
"设置 objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")\n"+ “设置 colItems = objWMIService.ExecQuery _ \n”+ " (\"从 Win32_Processor 选择 *\") \n"+ “对于 colItems 中的每个 objItem \n”+ “ Wscript.Echo objItem.ProcessorId \n”+ " exit for ' 仅执行第一个 cpu!\n"+ “下一个\n”;
结果类似于: ProcessorId = BFEBFBFF00010676
On http://msdn.microsoft.com/en-us/library/aa389273%28VS.85% 29.aspx 它说:
ProcessorId:描述处理器功能的处理器信息。对于 x86 类 CPU,字段格式取决于 CPUID 指令的处理器支持。如果支持该指令,则该属性包含 2(两个)DWORD 格式的值。第一个是偏移量 08h-0Bh,这是 CPUID 指令在输入 EAX 设置为 1 时返回的 EAX 值。第二个是偏移量 0Ch-0Fh,这是指令返回的 EDX 值。只有该属性的前两个字节是重要的,并且包含 CPU 复位时 DX 寄存器的内容 - 所有其他字节都设置为 0(零),并且内容为 DWORD 格式。
我不太明白;简单来说,它是唯一的还是只是此类处理器的一个编号,例如所有 Intel Core2 Duo P8400 都会有这个编号?
I used the code from http://www.rgagnon.com/javadetails/java-0580.html to get Motherboard Id, but the result is "null".
How can that be?
Also I modified the code a bit to look like this to get ProcessorId:
"Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")\n"+ "Set colItems = objWMIService.ExecQuery _ \n"+ " (\"Select * from Win32_Processor\") \n"+ "For Each objItem in colItems \n"+ " Wscript.Echo objItem.ProcessorId \n"+ " exit for ' do the first cpu only! \n"+ "Next \n";
The result is something like: ProcessorId = BFEBFBFF00010676
On http://msdn.microsoft.com/en-us/library/aa389273%28VS.85%29.aspx it says:
ProcessorId: 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.
I don't quite understand it; in plain English, is it unique or just a number for this class of processors, for instance all Intel Core2 Duo P8400 will have this number?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 eax 设置为 1 时,cpuid 操作码将在 eax 中返回处理器类型、系列等,并在 edx 中返回处理器功能。因此,您将得到的并不是唯一的东西,例如 CPU 序列号。
With eax set to 1, the cpuid opcode will return the processor type, familly, etc in eax, and the processor features in edx. So what you will get is not something unique, like the CPU serial number.