C#:如何知道是否某些Office 2003或2007应用程序的安装? [英] C#: How to know whether certain Office 2003 or 2007 application is installed?

查看:153
本文介绍了C#:如何知道是否某些Office 2003或2007应用程序的安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道微软的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 HKLM\SOFTWARE\Microsoft\Office\12.0\Word\InstallRoot.

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

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.

这篇关于C#:如何知道是否某些Office 2003或2007应用程序的安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆