简体   繁体   English

如何检查是否安装了 Office >= 2010?

[英]How to check if Office >= 2010 is installed?

How to check in WiX (Product.wxs) if Office is installed in version 2010, 2013, 2016, 2019 or later? 2010、2013、2016、2019及以后版本的Office如何查看WiX(Product.wxs)? 2007, 2003 or older should be ignored (as if Office is not installed at all).应忽略 2007、2003 或更早版本(就好像根本没有安装 Office)。

I'm aware of this question: C#: How to know whether certain Office 2003 or 2007 application is installed?我知道这个问题: C#:如何知道某个 Office 2003 或 2007 应用程序是否已安装? , but don't know how to check and combine multiple conditions in WiX. I totally can't come up with anything beyond what's in the above question... ,但不知道如何检查和组合 WiX 中的多个条件。除了上述问题之外,我完全想不出任何东西......

Thank you in advance.先感谢您。

I would not do that.我不会那样做。 There are too many options how office can be installed nowadays.现在安装 office 的选项太多了。 "Office 365" version that is installed with ClickToRun and not MSI as an example (and may use different registry keys), 32 vs 64 bit options, etc. User can even install office after installing your tool, or update office version later.与 ClickToRun 一起安装的“Office 365”版本而不是 MSI 作为示例(并且可能使用不同的注册表项),32 位与 64 位选项等。用户甚至可以在安装工具安装 office,或稍后更新 office 版本。

Instead, you could detect the version in your VSTO tool (use something like Application.Version for this).相反,您可以检测 VSTO 工具中的版本(为此使用Application.Version之类的东西)。 And simply give some error message if it's not the one your tool supports.如果您的工具不支持,只需给出一些错误消息。

Check out this topic as well for an overview: How to detect installed version of MS-Office?也请查看此主题以获得概述: How to detect installed version of MS-Office?

You can use a registry search like shown in the following snippet:您可以使用注册表搜索,如以下代码段所示:

<Property Id="OFFICEPATH">
  <RegistrySearch Id="OfficeReg" Root="HKLM" Key="SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot" Name="Path" Type="raw" />
</Property>

<Condition Message="This application requires Microsoft Office 2010. Please install Office then run this installer again.">
      <![CDATA[Installed OR (OFFICEPATH)]]>
</Condition>

Also you may consider using the Windows Installer APIs to find out if the relevant product/package/component codes are present on the machine.您也可以考虑使用Windows Installer API 来查明机器上是否存在相关的产品/包/组件代码。 These can be done via P/Invoke calls.这些可以通过 P/Invoke 调用完成。

Everything depends on which Office editions you need to support.一切都取决于您需要支持的 Office 版本。 There are Click2Run editions of MS Office that don't add the usual or necessary windows registry keys.有一些 MS Office 的Click2Run版本不添加通常或必要的 windows 注册表项。 In that case you need to have a special case for that, for example, if your add-in is for Outlook, you could check the following path in the windows registry:在这种情况下,您需要有一个特殊情况,例如,如果您的加载项是针对 Outlook 的,您可以在 windows 注册表中检查以下路径:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\Common\InstallRoot\Virtual\VirtualOutlook

Read more about that in the Determine whether Outlook is a Click-to-Run application on a computer确定 Outlook 是否是计算机上的即点即用应用程序中阅读更多相关信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM