Windows 32 或 64 位使用 HKEY_LOCAL_MACHINE\Software\WOW6432 节点

发布于 2024-08-24 00:26:19 字数 329 浏览 5 评论 0原文

我正在寻找一种非常简单的方法来确定客户使用的 Windows 版本是 32 位还是 64 位。我知道有一些使用 .NEt 的方法,但我希望避免它们。我只是想使用类似于下面的伪代码的东西,并想知道这个方法是否可靠。

If Registry Key exists (HKEY_LOCAL_MACHINE\Software\WOW6432Node)
   Then Assume 64bit
else
   Assume 32bit

谢谢!

编辑:更具体地说,我知道有几种不同的方法可以实现确定操作系统是 32 位还是 64 位的目标。但我想知道仅上述方法是否可靠。

I'm looking for a very simple way of determining if the version of Windows the customer is using is 32bit or 64bit. I know there are ways using .NEt but I'm looking to avoid them. I simply want to use something similar the below pseudo code and want to know if this method can be reliable.

If Registry Key exists (HKEY_LOCAL_MACHINE\Software\WOW6432Node)
   Then Assume 64bit
else
   Assume 32bit

Thanks!

EDIT: To be more specific, I know there a several different ways to accomplish the goal of finding out if the OS is 32 or 64bit. But I want to know if the above alone method would be reliable.

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

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

发布评论

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

评论(4

秋千易 2024-08-31 00:26:20

我假设您正在 32 位进程中运行(否则您已经知道答案了)。问题的解决方案是 IsWow64ProcessGetNativeSystemInfo

I assume you are running in a 32-bit process (otherwise you would already know the answer). The solution to your problem is either IsWow64Process or GetNativeSystemInfo.

残龙傲雪 2024-08-31 00:26:20

为什么不检查文件夹 C:\Program Files (x86) 是否存在?这将向您保证它是 64 位操作系统。

Why not check for the existence of the folder C:\Program Files (x86)? This will assure you that it's a 64bit OS.

寻梦旅人 2024-08-31 00:26:20

您可以检查环境变量PROCESSOR_ARCHITECTURE。如果是 AMD64 那么你使用的是 64 位操作系统,但这并不安全(阅读评论后)

但是为了安全起见,你可以调用 Win32 API,IsWow64Process,如本 来自 雷蒙德·陈

You can check the environment variable PROCESSOR_ARCHITECTURE. If it is AMD64 then you are on a 64 bit OS, but this is not safe (after reading comments)

But to be safe, you can call an Win32 API, IsWow64Process as mentioned in this blog post from Raymond Chen.

秋千易 2024-08-31 00:26:20

我希望这可以解决我在 Windows 8.1 64 位上尝试过的问题,它返回值 AMD64,

import _winreg
def get_registry_value(key, subkey, value):

  key = getattr(_winreg, key)
  handle = _winreg.OpenKey(key, subkey )
  (value, type) = _winreg.QueryValueEx(handle, value)
  return value

windowsbit = get_registry_value(
"HKEY_LOCAL_MACHINE",
"SYSTEM\\CurrentControlSet\Control\\Session Manager\\Environment",
"PROCESSOR_ARCHITECTURE")
print windowsbit

如果您在 64 位 Windows 机器上工作,则运行此代码,这将打印 AMD64

或者如果您在 32 位上工作将打印 AMD32

我希望这段代码可以帮助完全解决这个问题

i hope this can solve the problem i tried it on my windows 8.1 64 bit and it returns the value AMD64 for me

import _winreg
def get_registry_value(key, subkey, value):

  key = getattr(_winreg, key)
  handle = _winreg.OpenKey(key, subkey )
  (value, type) = _winreg.QueryValueEx(handle, value)
  return value

windowsbit = get_registry_value(
"HKEY_LOCAL_MACHINE",
"SYSTEM\\CurrentControlSet\Control\\Session Manager\\Environment",
"PROCESSOR_ARCHITECTURE")
print windowsbit

just run this code if you are working on 64 bit windows machine this will print AMD64

or if you are working on 32 bit it will print AMD32

i hope this code can help to solve this problem fully

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