Detect whether current Windows version is 32 bit or 64 bit

前端 未结 23 2852
抹茶落季
抹茶落季 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:20

    From a batch script:

    IF PROCESSOR_ARCHITECTURE == x86 AND
       PROCESSOR_ARCHITEW6432 NOT DEFINED THEN
       // OS is 32bit
    ELSE
       // OS is 64bit
    END IF
    

    Using Windows API:

    if (GetSystemWow64Directory(Directory, MaxDirectory) > 0) 
       // OS is 64bit
    else
       // OS is 32bit
    

    Sources:

    1. HOWTO: Detect Process Bitness
    2. GetSystemWow64Directory function

提交回复
热议问题