如何以编程方式确定我的机器是x86,x64还是IA64?
答案 0 :(得分:6)
在Windows系统上,您可以获取环境变量PROCESSOR_ARCHITECTURE。这是一篇MSDN文章,解释了可以返回的值。
PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_ARCHITECTURE=IA64 PROCESSOR_ARCHITECTURE=x86
答案 1 :(得分:1)
VBScript,检查PROCESSOR_ARCHITECTURE环境变量:
Set oShell = CreateObject("WScript.Shell")
Set oEnv = oShell.Environment("System")
Select Case LCase(oEnv("PROCESSOR_ARCHITECTURE"))
Case "x86"
' x86
Case "amd64"
' amd64
Case "ia64"
' ia64
Case Else
' other
End Select
VBScript,使用WMI:
Const PROCESSOR_ARCHITECTURE_X86 = 0
Const PROCESSOR_ARCHITECTURE_IA64 = 6
Const PROCESSOR_ARCHITECTURE_X64 = 9
strComputer = "."
Set oWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessors = oWMIService.ExecQuery("SELECT * FROM Win32_Processor")
For Each oProcessor In colProcessors
Select Case oProcessor.Architecture
Case PROCESSOR_ARCHITECTURE_X86
' x86
Case PROCESSOR_ARCHITECTURE_X64
' x64
Case PROCESSOR_ARCHITECTURE_IA64
' ia64
Case Else
' other
End Select
Next
答案 2 :(得分:0)
在C#中:
using System;
using Microsoft.Win32;
class Class1
{
static void Main(string[] args)
{
RegistryKey RegKey = Registry.LocalMachine;
RegKey = RegKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
Object cpuSpeed = RegKey.GetValue("~MHz");
Object cpuType = RegKey.GetValue("VendorIdentifier");
Console.WriteLine("You have a {0} running at {1} MHz.",cpuType,cpuSpeed);
}
}
答案 3 :(得分:0)
cat / proc / cpuinfo
答案 4 :(得分:0)
通常比底层处理器更重要的是操作系统运行的模式,添加到主机上安装的处理器。
检查“uname -p”(或uname(2))
的输出英特尔采用了AMD的64位指令扩展,因此值“x86_64”意味着您运行的是Intel或AMD 64位处理器,否则您将运行常规x86 ISA。
答案 5 :(得分:-1)
cpu-z是你想要的程序,它会告诉你你拥有哪个处理器以及它支持的扩展程序
答案 6 :(得分:-1)
在Java中你不应该知道。 ;)