[Ironpython-users] How can I detect whether I am running a 64.bit version of Windows?

Jeff Hardy jdhardy at gmail.com
Sat Feb 18 22:35:58 CET 2012


IsWow64Process()
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms684139(v=vs.85).aspx)
is the function you want, and you should be able to use ctypes to call
it from CPython and IronPython.

- Jeff

On Sat, Feb 18, 2012 at 8:42 AM, Vernon Cole <vernondcole at gmail.com> wrote:
> Thanks for your help, everyone.
>
> The following appears to do what I asked for:
> <Python>
> """is64bit() returns boolean value of detected Python word size"""
> def is64bit():
>     import sys
>     if sys.platform == 'cli': # IronPython
>         import System
>         return System.IntPtr.Size == 8
>     else:  # CPython
>         try:
>             return sys.maxsize > 2147483647
>         except AttributeError:
>             return False  # assume old versions of Python are 32 bit.
>
> if __name__ == "__main__":
>     print ("is64bit =", is64bit())
> </Python>
>
> Unfortunately <smacking head with hand and muttering "doh!">  I did not ask
> for what I actaully _needed_  :
>
> The correct question should have been:
> How do I detect whether I am running on a 64 bit version of Windows (even
> though I might be using 32 bit Python)?
> --
> Vernon
>
> On Mon, Feb 13, 2012 at 3:32 PM, Dino Viehland <dinov at microsoft.com> wrote:
>>
>> You can either check System.IntPtr.Size and see if it’s 4 or 8 (which is
>> what I’ve usually done in the past and works on all versions of .NET) or you
>> can check System.Environment.Is64BitProcess (this will read a little better,
>> but is new in .NET 4).
>>
>>
>>
>> From: ironpython-users-bounces+dinov=microsoft.com at python.org
>> [mailto:ironpython-users-bounces+dinov=microsoft.com at python.org] On Behalf
>> Of Vernon Cole
>> Sent: Monday, February 13, 2012 1:38 PM
>> To: ironpython-users at python.org
>> Subject: [Ironpython-users] How can I detect whether I am running ipy.exe
>> or ipy64.exe?
>>
>>
>>
>> I am testing adodbapi with IPy 2.7.2a2 -- using my new laptop which I have
>> set up as an everything in 64-bit test bed.
>>
>> My default test database is an .mdb (so-called ACCESS database) file.
>> Microsoft has decided that the JET engine, which has historically been used
>> to read and write that format is to be deprecated, so there is no 64 bit
>> version of it.  It is replaced by the Access Database Engine 2010
>> redistributable. Of course, the new software requires a different connection
>> string, one containing "Provider=Microsoft.ACE.OLEDB.12.0;".
>>
>> So, how can I tell which width of IronPython I am running, so I know which
>> connection string to use?
>> --
>> Vernon
>
>
>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>


More information about the Ironpython-users mailing list