function hasExcel2010(): Boolean;
var
MyReg: TRegistry;
begin
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\SOFTWARE\Microsoft\Office\14.0
Result := False;
MyReg := TRegistry.Create;
try
MyReg.RootKey := HKEY_LOCAL_MACHINE;
if MyReg.OpenKey('\SOFTWARE\', FALSE) then
begin
if MyReg.OpenKey('\SOFTWARE\Microsoft\Office\Software\Microsoft\Office\14.0', FALSE) then
begin
Result := True;
end
else if MyReg.OpenKey('\SOFTWARE\Microsoft\Office\14.0\Excel\InstallRoot', FALSE) then
begin
Result := MyReg.ValueExists('Path');
end
else if MyReg.OpenKey('\SOFTWARE\Microsoft\Office\14.0', FALSE) then
begin
Result := True;
end;
MyReg.CloseKey;
end;
finally
MyReg.Free;
end;
end;
function hasExcel2007(): Boolean;
var
MyReg: TRegistry;
begin
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Excel\InstallRoot\Path: C:\Program Files\...
Result := False;
MyReg := TRegistry.Create;
try
MyReg.RootKey := HKEY_LOCAL_MACHINE;
if MyReg.OpenKey('\SOFTWARE\', FALSE) then
begin
if MyReg.OpenKey('\SOFTWARE\Microsoft\Office\12.0\Excel\InstallRoot', FALSE) then
begin
Result := MyReg.ValueExists('Path');
end;
MyReg.CloseKey;
end;
finally
MyReg.Free;
end;
end;