Nol*_*rin 12
此代码显示简单的注册表检查将完成此任务.
这是转换为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");
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,这是不够好,以检查C:\Program Files\Microsoft Office\为mswordEXE文件,因为用户可能已经在其他地方安装了它.