c# - 检查系统中是否安装了 MSWord

标签 c# ms-word

完全重复:

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/

相关文章:

c# - 使用 Reflector 创建 VisualStudio 项目

c# - 使用 C# 编辑 HTML

ms-word - OpenXML 嵌套表

vba - 在word中选择粘贴的图片

c# - 用C#填充Word模板字段

python - 在 Python 中创建富文本文件 (rtf)

c# - 如何将项目(文本和值)添加到 ComboBox 并在 SelectedIndexChanged(SelectedValue = null)中读取它们

c# - Sprite 旋转 XNA

c# - 如何将二进制数据写入csv文件?

Delphi通过注册表检测Word版本