为何%PROCESSOR_ARCHITECTURE%总是返回86,而不是AMD64的 [英] Why %processor_architecture% always returns x86 instead of AMD64

查看:1757
本文介绍了为何%PROCESSOR_ARCHITECTURE%总是返回86,而不是AMD64的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找回环境变量检测系统是32位还是64位。
但是,64位服务器环境变量的%PROCESSOR_ARCHITECTURE%将返回 86 而不是 AMD64

I am trying to retrieve the environment variable to detect whether the system is 32 or 64 bit. But on 64 bit server the environment variable %processor_architecture% is returning x86 instead of AMD64.

有没有人有这个任何线索?

Does anyone has any clue about this?

推荐答案

您可能会得到错误的环境变量。如果你的应用程序在64位操作系统上运行32位应用程序这个环境变量的过程版本将返回86。如果你想找到的机器架构,你可以从下面的注册表项抢吧:

You may be getting the wrong environment variable. If your application is a 32-bit application running on a 64-bit OS the process version of this environment variable will return x86. If you want to find the architecture of the machine, you can grab it from the following registry entry:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE

或者,如果你使用.NET,那么你可以使用这个调用得到它:

Or if you're using .NET, then you can use this call to get it:

string arch = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", 
  EnvironmentVariableTarget.Machine);

在命令行中你可以试试这个:

From the command line you can try this:

reg query "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE

有是使用甚至更简单的解决方案 CMD

There is even a more simple solution using cmd:

ECHO %PROCESSOR_ARCHITECTURE%

这篇关于为何%PROCESSOR_ARCHITECTURE%总是返回86,而不是AMD64的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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