完全重复:
C#: How to know whether certain Office 2003 or 2007 application is installed?
如何使用C#代码查看系统是否安装了MSWord 2003 0r 2007?
最佳答案
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\
中检查 msword
EXE 文件还不够好,因为用户可能已将其安装在其他位置。
关于c# - 检查系统中是否安装了 MSWord,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/897633/