const
RegKeyDelphiRoot = '
Software\%s\%s\%d.0';
type
TDelphiVersion = (dlvDelphi5, dlvDelphi6, dlvDelphi7, dlvBDS3, dlvBDS4,
dlvRadStudio2007, dlvRadStudio2009);
function GetDelphiRegKey(Version: TDelphiVersion):
String;
begin
case Version
of
dlvDelphi5, dlvDelphi6, dlvDelphi7:
Result := Format(RegKeyDelphiRoot, ['
Borland', '
Delphi', Integer(Version) + 5]);
dlvBDS3, dlvBDS4, dlvRadStudio2007:
Result := Format(RegKeyDelphiRoot, ['
Borland', '
BDS', Integer(Version)]);
dlvRadStudio2009:
Result := Format(RegKeyDelphiRoot, ['
CodeGear', '
BDS', Integer(Version)]);
end;
end;
function GetDelphiRootDir(Version: TDelphiVersion):
String;
var
Reg: TRegistry;
begin
Result := '
';
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKeyReadOnly(GetDelphiRegKey(Version))
and Reg.ValueExists('
RootDir')
then
Result := Reg.ReadString('
RootDir');
finally
Reg.Free;
end;
end;
function IsDelphiInstalled(Version: TDelphiVersion): Boolean;
begin
Result := GetDelphiRootDir(Version) <> '
';
end;
function GetResCompilerExecutable(Version: TDelphiVersion):
String;
begin
Result := GetDelphiRootDir(Version);
if Result <> '
'
then
Result := IncludeTrailingPathDelimiter(Result) + '
Bin\brcc32.exe';
if not FileExists(Result)
then
Result := '
';
end;