从Windows注册表中获取Office应用程序的版本和平台 [英] Getting the version and platform of Office application from Windows Registry
问题描述
我正在为MS Office加载项安装Inno Setup安装程序,并试图找到一种方法,最好从Windows注册表中获取Excel和Outlook的版本和目标平台(位数).尽管某些非官方来源列出了一些从Windows注册表中提取版本信息的方法,但这些信息似乎不可靠.
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.
有人知道是否存在可靠(官方)的方法来从当前安装的Office(以及相关程序,例如Excel或Outlook)的版本中获取版本和平台信息?
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 ...
-
使用
HKEY_LOCAL_MACHINE
根并从下面的键中查询应用程序的路径...
Use
HKEY_LOCAL_MACHINE
root and query the path of the application from the keys below ...
Software\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE
Software\Microsoft\Windows\CurrentVersion\App Paths\excel.exe
查询这些键(Default)
的值时,您将获得文件系统上实际文件的路径,例如:
When query those keys (Default)
value you will get the path to the actual file on the filesystem, for example:
C:\Program Files\Microsoft Office\Root\Office16\OUTLOOK.EXE
请注意,您需要根据操作系统的位数使用KEY_WOW64_64KEY
或KEY_WOW64_32KEY
标志进行查询.
Please note you need to query according to the OS bitness with KEY_WOW64_64KEY
or KEY_WOW64_32KEY
flag.
使用此路径访问应用程序,并检索实际的文件属性"产品版本" ",例如16.0.8625.2121
.解析它以获得主要,次要和内部版本号.
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.
再次使用带有KEY_WOW64_64KEY
或KEY_WOW64_32KEY
标志的HKEY_LOCAL_MACHINE
来查询Bitness
键...
Once again use HKEY_LOCAL_MACHINE
with KEY_WOW64_64KEY
or KEY_WOW64_32KEY
flag to query the Bitness
key ...
Software\Microsoft\Office\%d.0\Outlook
%d
是产品的主要版本.如果返回值等于x64
已安装Outlook 64位版本.
Where %d
is the major version of the product. If returned value equal x64
Outlook 64 bit version installed.
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.
这篇关于从Windows注册表中获取Office应用程序的版本和平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!