Important: Please read the Qt Code of Conduct -

Detect 64 bit os window.

  • I want to find on which type OS is running .My main concern is to check is weather it's 64 bit OS or 32 bit.

  • Lifetime Qt Champion


    For what do you need that kind of check ?

  • #ifdef Q_OS_WIN32
    qDebug()<<"This is window os 32 -now run my abc32.exe ";

    This work for me to detect windows 32 bit OS

    But i want code that satisfy my condition that i am on windows OS of 64 bit.
    in this condition i want to run my abc64.exe .

  • Lifetime Qt Champion

    Then you should write a little launcher app that use Q_OS_WIN32 and Q_OS_WIN64 to start the correct executable. Or just have an installer that will only install the correct version of your application depending on the OS

  • Its not going in the case Q_OS_WIN64 is i am using OS win64 bit .That's the main problem.
    #ifdef Q_OS_WIN64
    #ifdef Q_OS_WIN32

  • Do you want to detect at compile time or at runtime ???

    If you want to detect at runtime, all the suggestions which use pre-processor macros won't work at all! I think you can use QSysInfo::windowsVersion() to detect which version of Windows you are running on. Then: If you program was compiled as a 64-Bit binary, you must be running on the 64-Bit edition. Otherwise, if you compiled as 32-Bit binary, simply call IsWow64Process(), which will return true on 64-Bit OS and false on 32-Bit OS.


    Warning: IsWow64Process() does NOT exist on WindowsXP or even older. You should check for the availability of the function using QLibrary or LoadLibrary, rather than calling it directly. If the function does NOT exist in "Kernel32.dll", you are definitely running on an (old) 32-Bit OS.


    static BOOL IsWow64()
    BOOL bIsWow64 = FALSE;
    LPFN_ISWOW64PROCESS fnIsWow64Process = NULL;

    fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
    if(NULL != fnIsWow64Process)
        if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
            //handle error
    return bIsWow64;


    bool running_on_64_bits_os(void)
    #if defined(_M_X64) || defined(x86_64)
    return true;
    return (IsWow64() == TRUE);

    See also:
    "IsWow64Process function":

  • Lifetime Qt Champion

    Indeed !

    I was thinking of a OS specific launcher but that would have been the snake biting it's tail... Need some rest... :D

  • MuldeR thank you .I got the solution form your help.
    SGaist thank you to .Thumbs up

Log in to reply