2004. szeptember 9., csütörtök
How to check whether a program is available on a PC
Problem/Question/Abstract:
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?
Answer:
For the MS Word case, you might want to start Word in automation mode to see if its present. The following routine does that:
function IsWordPresent(var IsActive: Boolean): Boolean;
var
MSWord: Variant;
begin
Result := False;
IsActive := False;
try
MSWord := GetActiveOleObject('Word.Application');
Result := not VarIsEmpty(MSWord);
IsActive := not VarIsEmpty(MSWord)
except
MSWord := Unassigned
end;
if VarIsEmpty(MSWord) then
begin
try
MSWord := CreateOleObject('Word.Application');
Result := not VarIsEmpty(MSWord);
if Result then
MSWord.Quit
except
end;
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése