Getting the version and platform of an Office application from the Windows registry

I am working on the Inno Setup installer for the MS Office add-on and trying to find a way to get the version and target platform (bitt) of Excel and Outlook, preferably from the Windows registry. Although some unofficial sources list some ways to extract version information from the Windows registry, this information seems unreliable.

Does anyone know if there is a reliable (and official) way to get version and platform information from the version of Office (and related programs such as Excel or Outlook) that are currently installed?

+1
excel-addins registry inno-setup outlook-addin office-addins
Nov 22 '17 at 9:29 on
source share
2 answers

Listed below are the steps to get information ...

  • Use HKEY_LOCAL_MACHINE root and request the application path from the keys below ...

     Software\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE Software\Microsoft\Windows\CurrentVersion\App Paths\excel.exe 

    When you request these keys (Default) value, you will get the path to the actual file in the file system, for example:

     C:\Program Files\Microsoft Office\Root\Office16\OUTLOOK.EXE 

    Please note that you need to request the KEY_WOW64_64KEY or KEY_WOW64_32KEY flag according to the OS protection KEY_WOW64_32KEY .

  • Use this path to the application and get the actual property of the file "Product Version", for example 16.0.8625.2121 . Disassemble it to get primary, secondary and lowercase numbers.

  • Again use HKEY_LOCAL_MACHINE with the flag KEY_WOW64_64KEY or KEY_WOW64_32KEY to request the Bitness key ...

     Software\Microsoft\Office\%d.0\Outlook 

    Where %d is the main version of the product. If the returned value is x64 version of the 64-bit version of Outlook.

EDIT:

You can find several solutions (even some spatial ones for Inno Setup). Determine if Office is 32-bit or 64-bit through the registry . Please check it.

+1
Nov 22 '17 at 17:30
source share

Based on the answers of @Slava Ivanov and @MB. , code for Inno Setup

 const AppPathsKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'; const SCS_32BIT_BINARY = 0; SCS_64BIT_BINARY = 6; function GetBinaryType(ApplicationName: string; var BinaryType: Integer): Boolean; external 'GetBinaryTypeW@kernel32.dll stdcall'; function GetAppVersionAndBinaryType( ProgramFileName: string; var Version: string; var BinaryType: Integer): Boolean; var ProgramPath: string; begin Result := RegQueryStringValue(HKLM, AppPathsKey + '\' + ProgramFileName, '', ProgramPath); if not Result then begin Log(Format('Cannot find a path to "%s"', [ProgramFileName])); end else begin Log(Format('Path to "%s" is "%s"', [ProgramFileName, ProgramPath])); Result := GetVersionNumbersString(ProgramPath, Version); if not Result then begin Log(Format('Cannot retrieve a version of "%s"', [ProgramFileName])); end else begin Log(Format('Version of "%s" is "%s"', [ProgramFileName, Version])); Result := GetBinaryType(ProgramPath, BinaryType); if not Result then begin Log(Format('Cannot retrieve a binary type of "%s"', [ProgramFileName])); end else begin Log(Format('Binary type of "%s" is "%d"', [ProgramFileName, BinaryType])); end; end; end; end; 



Code for Unicode version of Inno Setup .

+1
Nov 22 '17 at 20:49
source share



All Articles