Last Updated: February 25, 2016
·
1.528K
· malte70

Detect weather unter x86 or x64 Windows

There are many ways to detect weather your application runs in a 32 bit environment or a 64 bit environment. This is the simplest way I could find (it also detects wine):

import ctypes, os, platform
def GetBits()
    """
    returns "32bit", "64bit", "wow64" or "wine"
    """
    try:
        ctypes.windll.kernel32.wine_get_unix_file_name()
        return "wine"
    except AttributeError:
        arch = platform.architecture()[0]
        return "wow64" if arch=="32bit" and ("PROGRAMFILES(X86)" in os.environ) else arch