How to figure out if the platform is 32bit or 64bit?
Tim Golden
mail at timgolden.me.uk
Wed Jul 16 10:01:58 EDT 2008
Fredrik Lundh wrote:
> Ken Hartling wrote:
>
> > Thanks .. but I want to find out if the system is "running on 64bit"
> > even when the interpreter is a 32-bit build executable ("what python
> > was built on"). platform.architecture() and platform() in general
> > seems to only be looking at the build executable
>
> You can pass in an arbitrary binary to architecture(), so I guess you
> could use this on some suitable thing under "/bin" on a Unix box. This
> doesn't work on Windows, though.
>
> In this message,
>
> http://mail.python.org/pipermail/python-list/2005-June/326158.html
>
> Thomas Heller suggests using ctypes to call the Windows API directly; so
> something like this could work:
>
> >>> import ctypes, sys
> >>> i = ctypes.c_int()
> >>> kernel32 = ctypes.windll.kernel32
> >>> process = kernel32.GetCurrentProcess()
> >>> kernel32.IsWow64Process(process, ctypes.byref(i))
> 1
> >>> is64bit = (i.value != 0)
> >>> is64bit
> False
This is included in the latest pywin32-211 as well:
<code>
import win32process
print win32process.IsWow64Process ()
</code>
TJG
More information about the Python-list
mailing list