From 3d148038b429b53bf9144fbc07a6f261f69d0dd2 Mon Sep 17 00:00:00 2001 From: cournape Date: Wed, 9 Sep 2009 02:36:45 +0000 Subject: [PATCH] Fix win64 detection. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4352 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Tool/MSCommon/common.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index f74d10cb..017892cf 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -54,7 +54,9 @@ else: _is_win64 = None def is_win64(): - """Return true if running on windows 64 bits.""" + """Return true if running on windows 64 bits. + + Works whether python itself runs in 64 bits or 32 bits.""" # Unfortunately, python does not provide a useful way to determine # if the underlying Windows OS is 32-bit or 64-bit. Worse, whether # the Python itself is 32-bit or 64-bit affects what it returns, @@ -63,17 +65,22 @@ def is_win64(): # avoid repeated registry calls. global _is_win64 if _is_win64 is None: - try: - yo = read_reg(r'Software\Wow6432Node') - except WindowsError: - yo = None - _is_win64 = (yo is not None) + _is_win64 = has_reg(r"Software\Wow6432Node") return _is_win64 def read_reg(value): return SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, value)[0] +def has_reg(value): + """Return True if the given key exists in HKEY_LOCAL_MACHINE, False + otherwise.""" + try: + SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, value) + ret = True + except WindowsError: + ret = False + return ret # Functions for fetching environment variable settings from batch files. -- 2.26.2