C#:如何知道是否某些Office 2003或2007应用程序的安装?应用程序、Office

由网友(非法盗墓者 -)分享简介:我需要知道微软的Word,Excel,Outlook中,项目等安装在Windows窗体.NET 2.0 C#应用程序。第一次尝试是简单地尝试创建应用对象和捕捉任何异常,但这样太耗费时间。有没有更快的方法来检测呢?如检查注册表值,或另一种技术与COM包装?I need to know whether Microso...

我需要知道微软的Word,Excel,Outlook中,项目等安装在Windows窗体.NET 2.0 C#应用程序。 第一次尝试是简单地尝试创建应用对象和捕捉任何异常,但这样太耗费时间。 有没有更快的方法来检测呢?如检查注册表值,或另一种技术与COM包装?

I need to know whether Microsoft Word, Excel, Outlook, Project, etc are installed in a Windows Forms .net 2.0 C# application. The first attempt was by simply trying to create the application objects and catching any exception, but this is too time consuming. Is there any faster way to detect this? Like checking registry values, or another technique with the COM wrappers?

推荐答案

您可以使用MSI(Windows安装程序)的API,以找出是否相关的产品/包装/组件codeS是在机器上present 。这些都是相当简单的通过P / Invoke来使用。

You can use the MSI (Windows Installer) APIs to find out if the relevant product/package/component codes are present on the machine. These are fairly simple to use via P/Invoke.

另外,你可以看看在注册表中。 Word 2007中,例如,把它的安装位置在 HKLM SOFTWARE 微软办公室 12.0 字 InstallRoot

Alternatively, you can look in the registry. Word 2007, for example, puts its install location at HKLMSOFTWAREMicrosoftOffice12.0WordInstallRoot.

这不会帮助你,如果你打算使用互操作的组件,但它的确实的告诉你,以合理的确定性,是否安装了各种各样的事情。

This doesn't help you if you're planning on using the interop components, but it does tell you, with reasonable certainty, whether the various things are installed.

阅读全文

相关推荐

最新文章