问题描述
如何使用.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)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!