C# How do you get the operating system architecture (x86 or x64)? [duplicate]

匆匆过客 提交于 2019-12-06 04:09:11

问题


Possible Duplicate:
How to detect Windows 64 bit platform with .net?

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

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.

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


回答1:


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

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"));


来源:https://stackoverflow.com/questions/3639129/c-sharp-how-do-you-get-the-operating-system-architecture-x86-or-x64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!