Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Detect 64 bit os window.
Forum Updated to NodeBB v4.3 + New Features

Detect 64 bit os window.

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 6.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vivekmalik2466
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      For what do you need that kind of check ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vivekmalik2466
        wrote on last edited by
        #3

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

        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 .

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vivekmalik2466
            wrote on last edited by
            #5

            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
            qDebug()<<"Q_OS_WIN64---------------";
            codecTool="ffmpeg/win64/ffmpeg";
            #endif
            #ifdef Q_OS_WIN32
            qDebug()<<"Q_OS_WIN32--------------";
            codecTool="ffmpeg/win32/ffmpeg";
            #endif@

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MuldeR
              wrote on last edited by
              #6

              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.

              @typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

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

              fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
                  GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
              
              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;
              #else
              return (IsWow64() == TRUE);
              #endif
              }@

              See also:
              "IsWow64Process function":http://tinyurl.com/iswow64

              My OpenSource software at: http://muldersoft.com/

              Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

              Go visit the coop: http://youtu.be/Jay...

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Indeed !

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

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vivekmalik2466
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved