Best way to confirm Microsoft Office Applications present on System  
Author Message
GavH





PostPosted: Visual C# General, Best way to confirm Microsoft Office Applications present on System Top

Hi,

What would be the most precise way to confirm the existance of Microsoft Office applications from a running application.

For example how can I confirm that Outlook is installed, or Word is inastalled, what would be the 'best practice' method to confirm this or any installation information, to the highest degree of accuracy.

Thanks for any ideas.



Visual C#17  
 
 
ahmedilyas





PostPosted: Visual C# General, Best way to confirm Microsoft Office Applications present on System Top

well there isnt really. One is to look in the registry keys however you will have permission issues as well as perhaps invalid registry entries. The other is to look in the program files folder of the system and see if the items are installed but you need to know which items will be office specific. One other method is to see if you can start the process, like "outlook" or "winword" but the problem there is that it will launch the application, which you don't want. However should you run this, you will get a Win32Exception if the application is not installed or perhaps if the keywords are not registered/assigned to Windows.

I guess the best way may well be to look into the registry and just read the keys. There isn't a best practice in this scenario but a "as close to as possible"



 
 
GavH





PostPosted: Visual C# General, Best way to confirm Microsoft Office Applications present on System Top

Thanks for the discussion.

I wanted to avoid the registry due to the likely hood of 'errors' (although not all that likely) and the more likely problem of permissions within multi user environments.

The application I am working on interops directly with the Microsoft Office applications, so a possible scenareo could be to attempt application execution (with the ui hidden) through interop and catch any exceptions, Once the test had been completed once, and the locations of the Office executables are known (through interop), perhaps a simple File.Exists() test would surfice.

Thanks for your input.



 
 
ahmedilyas





PostPosted: Visual C# General, Best way to confirm Microsoft Office Applications present on System Top

Its just one of those things unfortunately.

you could get a list of files which are "Office" related files only using the Directory.GetFiles(), and get files in the program files folder and see if the specific files do exist but then again, it could be that it does exist but not installed!

you could do the thing as suggested and you pointed out about launching the process and catch the exception, but exceptions are expensive and really should aim for a better solution.

I would say check the registry for the office key and also check the office installation folder, should the registry store the information about where office is installed - this would be a good solution to be honest. If either one returns false, then we know that office isn't installed correctly.



 
 
GavH





PostPosted: Visual C# General, Best way to confirm Microsoft Office Applications present on System Top

Yes I agree that using Exceptions to direct program flow is a costly process, and not a direction I favour.

If I was only required to check the existence of one application I would most likely throw caution to the wind and attempt access through a PIA Assembly, using the Exception to decide compatibility/existence of the required office application, however I have a selection of applications to access, pretty much the entire office suite, at least potentially.

The installation location for the office applications does exist in the registry on HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\[$VER$\$APPLICATION$\InstallRoot which could be followed, then as you suggest the registry and disk location can both be checked providing the best picture as to the 'state' of the install. If either of these steps fail I can safely disable the interop functionality for that application.

The applicable key should be readable by all users by default, based on its HKEY_LOCAL_MACHINE\SOFTWARE\ location, if it is not then, I can safely disable as they are running on an extremely crippled account as applications including office will not be able to access machine data,

The registry check can cross examine HKEY_CURRENT_USER for stored office settings to assure that the current user has office installed, unfortunatley the install root is only stored under the LOCAL_MACHINE key, so the CURRENT_USER check will be required as a further level of confirmation, that office is installed for this user.

Thanks
ahmedilyas