Detect whether Office is 32bit or 64bit via the re

2019-01-07 06:54发布

Now that Office also comes in a 64bit install, where in the registry do you find out if the version of Office installed is 32bit or 64bit?

27条回答
来,给爷笑一个
2楼-- · 2019-01-07 07:20

I wrote this for Outlook at first. Modified it a little for Word, but it will not work on a standalone install because that key does not show the bitness, only Outlook does.

Also, I wrote it to only support current versions of Office, =>2010

I stripped all the setup and post processing...

:checkarch
    IF NOT "%PROCESSOR_ARCHITECTURE%"=="x86" SET InstallArch=64bit
    IF "%PROCESSOR_ARCHITEW6432%"=="AMD64" SET InstallArch=64bit
    IF "%InstallArch%"=="64bit" SET Wow6432Node=\Wow6432Node
GOTO :beginscript

:beginscript
SET _cmdDetectedOfficeVersion=reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer"
@FOR /F "tokens=* USEBACKQ" %%F IN (`!_cmdDetectedOfficeVersion! 2^>NUL `) DO (
SET _intDetectedOfficeVersion=%%F
)
set _intDetectedOfficeVersion=%_intDetectedOfficeVersion:~-2%


:switchCase
:: Call and mask out invalid call targets
    goto :case!_intDetectedOfficeVersion! 2>nul || (
:: Default case
    ECHO Not installed/Supported
    )
  goto :case-install

:case14
    Set _strOutlookVer= Word 2010 (!_intDetectedOfficeVersion!)
    CALL :GetBitness !_intDetectedOfficeVersion!
    GOTO :case-install  
:case15
    Set _strOutlookVer= Word 2013 (!_intDetectedOfficeVersion!)
    CALL :GetBitness !_intDetectedOfficeVersion!
    GOTO :case-install
:case16
    Set _strOutlookVer= Word 2016 (!_intDetectedOfficeVersion!)
    CALL :GetBitness !_intDetectedOfficeVersion!
    goto :case-install
:case-install
    CALL :output_text !_strOutlookVer! !_strBitness! is installed
GOTO :endscript


:GetBitness
FOR /F "tokens=3*" %%a in ('reg query "HKLM\Software%Wow6432Node%\Microsoft\Office\%1.0\Outlook" /v Bitness 2^>NUL') DO Set _strBitness=%%a
GOTO :EOF
查看更多
小情绪 Triste *
3楼-- · 2019-01-07 07:21

I've previously blindly followed the answer based on the MSDN docs. Today, this turned out to be less than required. On a machine with Office Home and Student installed, which doesn't include Outlook, HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Outlook was present, but HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Outlook was not. I've now changed my code to first look for the "plain" non-Wow6432Node version. If that's present, it'll be used. If not, it will continue by looking at the Wow6432Node version. This is being checked in an Inno Setup-based installer - I don't know which APIs Inno Setup uses. If your app doesn't access the registry in the same way, you might see different results.

查看更多
Summer. ? 凉城
4楼-- · 2019-01-07 07:21

This Wikipedia article states:

On 64-bit versions of Windows, there are two folders for application files; the "Program Files" folder contains 64-bit programs, and the "Program Files (x86)" folder contains 32-bit programs.

So if the program is installed under C:\Program Files it is a 64-bit version. If it is installed under C:\Program Files (x86) it is a 32-bit installation.

查看更多
乱世女痞
5楼-- · 2019-01-07 07:24

If one wants to know only what bit number an installed version of Office 2010 is, then in any application of Office 2010, just click on File, then on Help. Information about version number will be listed, and next to that, in parentheses, will be either (32-bit) or (64-bit).

查看更多
【Aperson】
6楼-- · 2019-01-07 07:25

This InnoSetup code is working for me under Win 10x64 and Office 2016 x86 (using 'HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration' and key 'Platform')

[Code]
const
  RegOffice='SOFTWARE\Microsoft\Office\ClickToRun\Configuration';
  RegOfficeKey='Platform';

/// <summary>
/// Get current HKLM version
/// </summary>
function GetHKLM: Integer;
begin
  if IsWin64 then
    Result := HKLM64
  else
    Result := HKLM32;
end;

/// <summary>
/// Check is Microsoft Office is installed or not
/// </summary>
function IsOfficeInstalled (): Boolean;
var
  platform: string;
begin
  RegQueryStringValue(GetHKLM(), RegOffice, RegOfficeKey, platform);
  if platform = 'x86' then begin
   SuppressibleMsgBox('Microsoft Office found (x86 version)' , mbConfirmation, MB_YESNO or MB_DEFBUTTON1, IDYES);
    Result := True;
  end else if platform = 'x64' then begin
    SuppressibleMsgBox('Microsoft Office found (x64 version)', mbConfirmation, MB_YESNO or MB_DEFBUTTON1, IDYES);
    Result := True;
  end else begin
    SuppressibleMsgBox('Microsoft Office NOT found' + platform + '.', mbConfirmation, MB_YESNO or MB_DEFBUTTON1, IDYES);
    Result := False;
  end;
end;
查看更多
唯我独甜
7楼-- · 2019-01-07 07:27

Open Outlook 2013 > File > Office account > About Outlook > click large "? About Outlook" button > read popup description

查看更多
登录 后发表回答