Detect whether current Windows version is 32 bit or 64 bit

前端 未结 23 2411
抹茶落季
抹茶落季 2020-11-28 03:47

Believe it or not, my installer is so old that it doesn\'t have an option to detect the 64-bit version of Windows.

Is there a Windows DLL call or (even better) an en

相关标签:
23条回答
  • 2020-11-28 04:39

    For a VBScript / WMI one-liner that retrieves the actuals bits number (32 or 64) of the OS or the Hardware, take a look at http://csi-windows.com/toolkit/csi-getosbits

    0 讨论(0)
  • 2020-11-28 04:41

    I don't know on which Windows version it exists, but on Windows Vista and later this runs:

    Function Is64Bit As Boolean
        Dim x64 As Boolean = System.Environment.Is64BitOperatingSystem
        If x64 Then
           Return true
        Else
           Return false
        End If
    End Function
    
    0 讨论(0)
  • 2020-11-28 04:44

    To check for a 64-bit version of Windows in a command box, I use the following template:

    test.bat:

    @echo off
    if defined ProgramFiles(x86) (
        @echo yes
        @echo Some 64-bit work
    ) else (
        @echo no
        @echo Some 32-bit work
    )
    

    ProgramFiles(x86) is an environment variable automatically defined by cmd.exe (both 32-bit and 64-bit versions) on Windows 64-bit machines only.

    0 讨论(0)
  • 2020-11-28 04:45

    Answer for Newer Versions of Windows

    Today, I posted some code on another question and an explanation of how to do this with IsWow64Process2 for Windows 10 version 1511 or later and Windows Server 2016. Additionally, the code determines if the process is 32 or 64 bit and whether the process is running under the WOW64 emulator.

    One of the main reasons I have posted the answer is because while there were several suggestions to use IsWow64Process2, no code that I saw showed how.

    Please see the answer here: https://stackoverflow.com/a/59377888/1691559

    0 讨论(0)
  • 2020-11-28 04:46

    The best way is surely just to check whether there are two program files directories, 'Program Files'and 'Program Files (x86)' The advantage of this method is you can do it when the o/s is not running, for instance if the machine has failed to start and you wish to reinstall the operating system

    0 讨论(0)
提交回复
热议问题