C#: How to know whether certain Office 2003 or 2007 application is installed?

后端 未结 2 1895
耶瑟儿~
耶瑟儿~ 2020-12-20 04:12

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

2条回答
  •  既然无缘
    2020-12-20 04:32

    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.

    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.

提交回复
热议问题