C# 如何获取操作系统架构(x86 或 x64)?

发布于 2024-09-17 11:11:54 字数 343 浏览 2 评论 0原文

可能的重复:
如何使用.net检测Windows 64位平台?

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

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

如果在 .NET 2.0 中找不到任何内容,请告诉我。 :)

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. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以往的大感动 2024-09-24 11:11:54

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

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

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

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"));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文