I'm working on a Inno Setup installer for an MS Office Add-In and trying to find a way to get the version and target platform (bitness) of Excel and Outlook, preferably from the Windows Registry. Although some unofficial sources list some methods to extract version information from the Windows Registry, that information appears to be unreliable.
Does anyone know if there is a reliable (and official) way to get version and platform information from the version of Office (and associated programs such Excel or Outlook) that is currently installed?
The following are the steps to get the information ...
Use
HKEY_LOCAL_MACHINE
root and query the path of the application from the keys below ...When query those keys
(Default)
value you will get the path to the actual file on the filesystem, for example:Please note you need to query according to the OS bitness with
KEY_WOW64_64KEY
orKEY_WOW64_32KEY
flag.Use this path to an application and retrieve actual file property "Product version" for example
16.0.8625.2121
. Parse it to get major, minor and build numbers.Once again use
HKEY_LOCAL_MACHINE
withKEY_WOW64_64KEY
orKEY_WOW64_32KEY
flag to query theBitness
key ...Where
%d
is the major version of the product. If returned value equalx64
Outlook 64 bit version installed.EDIT:
There are few more solutions (even some spacial for Inno Setup) can be found at Detect whether Office is 32bit or 64bit via the registry thread. Please check it out.
Based on the answers by @Slava Ivanov and @MB., a code for Inno Setup is:
The code is for Unicode version of Inno Setup.