[英]Best way to check for Office (Word) 2007
I have setup spell checking through WinWord but I need to find a way to in sure that Word 2007 is installed on there systems. 我通过WinWord进行了拼写检查,但是我需要找到一种方法来确保在该系统上安装了Word 2007。
I have seen the Registry Versions of this but I also read that it can provide false positives. 我已经看到了它的注册表版本,但我也读到它可以提供误报。 So I am in the 'market' as it were to figure out how to accomplish this. 所以我在“市场”上,要弄清楚如何做到这一点。 Can it be as simple as doing a File.Exists()
on WinWord.exe in the 2007 file path? 是否可以像在2007文件路径中的File.Exists()
上执行File.Exists()
一样简单?
Any other ideas? 还有其他想法吗?
Type word = Type.GetTypeFromProgID("Word.Application");
if (word != null) {
// Word is installed
}
To check that Word 2007 in particular is installed: 要检查是否特别安装了Word 2007:
Type word = Type.GetTypeFromProgID("Word.Application.12");
if (word != null) {
// Word 2007 is installed
}
The best way would be use a combination. 最好的方法是结合使用。 Use the registry to get the installation path. 使用注册表获取安装路径。 Inside of that path, you should find the executable. 在该路径内,您应该找到可执行文件。 A false positive occurs because upgrades and uninstalls will sometimes remove the file but not the registry entry. 出现误报是因为升级和卸载有时会删除文件,但不会删除注册表项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.