views:

95

answers:

3

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?

+4  A: 
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
}
Darin Dimitrov
Slick solution.
statenjason
Does the ProdID "Word.Application" specifically find Word 2007?
John K
Sorry, that comment was ambiguous - to be more specific I meant to say the author requested Word 2007 be identified to the exclusion of other versions of Word on the system.
John K
Then the second test should work fine for you.
Darin Dimitrov
Very, very nifty. Thanks! I was told at the onset that ALL systems would be Office 2007 but the reality is that they all WILL be but currently are not and I only implemented 07 spell checking.
Refracted Paladin
A: 

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

mcauthorn
A: 

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.

James Bailey