完全重复:
C#: How to know whether certain Office 2003 or 2007 application is installed?
如何使用C#代码检查系统中是否安装了MSWord 2003 0r 2007?
答案 0 :(得分:12)
This code表明一个简单的注册表检查就可以完成这项工作。
以下是转换为C#的代码(稍微改进以使用using
语句)。
using Microsoft.Win32;
// Check whether Microsoft Word is installed on this computer,
// by searching the HKEY_CLASSES_ROOT\Word.Application key.
using (var regWord = Registry.ClassesRoot.OpenSubKey("Word.Application"))
{
if (regWord == null)
{
Console.WriteLine("Microsoft Word is not installed");
}
else
{
Console.WriteLine("Microsoft Word is installed");
}
}
请注意,检查C:\Program Files\Microsoft Office\
EXE文件的msword
是不够的,因为用户可能已将其安装在其他位置。
答案 1 :(得分:0)
其中一个解决方案,我认为如果你谷歌它会更好。 要检查是否安装了Excel,我使用此c#代码
Excel.Application app = new Excel.ApplicationClass();
如果app == null
表示excel未安装在计算机上。如果您查看MSDN文档,您应该能够获得打开单词appln的语法。