简体   繁体   中英

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.

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?

Any other ideas?

Type word = Type.GetTypeFromProgID("Word.Application");
if (word != null) {
    // Word is installed
}

To check that Word 2007 in particular is installed:

Type word = Type.GetTypeFromProgID("Word.Application.12");
if (word != null) {
    // Word 2007 is installed
}

If you are worried about the registry and false positives you can look at the exe version. Microsoft documents how to determine the executable version here

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM