2010-07-28 30 views
0

我正在寻找一种可靠的方式来确定Windows操作系统体系结构(32位或64位),对Windows版本或Windows版本不敏感系统区域设置/显示语言。我将使用C#来执行此操作。为了澄清,我需要OS架构,而不是处理器架构,而不是应用程序架构。以非本地语言敏感的方式确定Windows操作系统体系结构

我知道我可以使用IntPtr.Size,但这取决于应用程序的目标体系结构。

我也尝试使用System.Management.ManagementClass从Win32_OperatingSystem中获取“OSArchitecture”属性。但是,这个值取决于显示语言而改变。 (例如,如果我将显示语言设置为西班牙语,我会得到“64位”,而在英语中,它是“64位”。)

谢谢!

回答

1

这里是一个答案How to detect Windows 64 bit platform with .net?

基本上,你可以先检查过程的类型,做到这一点,然后调用正确的方法做正确的检查。

+0

感谢您的帮助。这可能是我最终会结束的。 – Tom 2010-07-29 17:34:16

0

对于有同样问题的任何人来说,这似乎也是一个窍门。我不能肯定这是多么强大的:

 


public bool Is64Bit() { 
    return (System.Environment.GetEnvironmentVariable("ProgramFiles(x86)") != null); 
} 

 
1

入门安装了Windows架构:

string getOSArchitecture() 
    { 
     if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86))) 
      return "64-bit"; 
     return "32-bit"; 
    } 
相关问题