Author: Jonas Bilinkevicius
How do you find out whether a program is available ? For example, how can you
programmatically tell whether MS Word 2000 is installed rather than Lotus WordPro?
The OS can be Win95, 98, ME, 2000, NT4. I did not find any Win API function
allowing to find out if a specific application exists on the machine. The nearest I
found is the FindExecutable function but you need to pass it a document file name.
Should I read the registry, to enumerate the currently installed applications?
For the MS Word case, you might want to start Word in automation mode to see if its
present. The following routine does that:
1 2 function IsWordPresent(var IsActive: Boolean): Boolean;
3 var4 MSWord: Variant;
5 begin6 Result := False;
7 IsActive := False;
8 try9 MSWord := GetActiveOleObject('Word.Application');
10 Result := not VarIsEmpty(MSWord);
11 IsActive := not VarIsEmpty(MSWord)
12 except13 MSWord := Unassigned
15 if VarIsEmpty(MSWord) then16 begin17 try18 MSWord := CreateOleObject('Word.Application');
19 Result := not VarIsEmpty(MSWord);
20 if Result then21 MSWord.Quit
22 except23 end;