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

查看:60
本文介绍了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天全站免登陆