C#如何获得操作系统体系结构(x86或x64)? [英] C# How do you get the operating system architecture (x86 or x64)?

查看:475
本文介绍了C#如何获得操作系统体系结构(x86或x64)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何使用.net检测Windows 64位平台?

如何使用.NET 2.0检索操作系统体系结构(x86或x64)?

How can I retrieve the operating system architecture (x86 or x64) with .NET 2.0?

我没有找到任何好的方法来在Google上获取操作系统架构。我发现的是如何判断该进程是32位还是64位。

I have not found any good method to get the OS architecture on Google. What I found was how to tell whether the process is 32-bit or 64-bit.

如果在.NET 2.0中仍然找不到答案,请告诉我。 :)

If there isn't anyway to find out in .NET 2.0 please tell me. :)

推荐答案

不是重复问题中可接受的答案,但这是我的方法:

Not the accepted answer in the duplicate question, but this is how I'd do it:

使用 GetEnvironmentVariable 查找PROCESSOR_ARCHITEW6432变量。如果不存在,则必须运行32位:

Use GetEnvironmentVariable to look for the PROCESSOR_ARCHITEW6432 variable. If it doesn't exist, you must be running 32bit:

bool is64bit = !string.IsNullOrEmpty(
    Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"));

这篇关于C#如何获得操作系统体系结构(x86或x64)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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