Return the library path of a specific platform using OTA

244 views Asked by At

I want to get the library path for a specific platform (win32, win64, OSx). But, when I ask for the library path for, OTA just return me the OSx library path.

The code is:

EnvironmentOptions := (BorlandIDEServices as IOTAServices).GetEnvironmentOptions;
Paths.Text := EnvironmentOptions.Values['LibraryPath'];

I noticed a strange thing. When I ask for the key values I get 3 LibraryPath.

When I do:

EnvironmentOptions.GetOptionNames

I get:

... A lot of values 
'ClassCompletionBooleanAddInterface', tkEnumeration
'LibraryPath', tkLString                --> 1
'PackageDPLOutput', tkLString
...  lot of values 
'LibraryPath', tkLString                --> 2
'PackageDPLOutput', tkLString
...  lot of values 
'HPPOutputDirectory', tkLString
'LibraryPath', tkLString                --> 3
'PackageDPLOutput', tkLString
...  lot of values 

I THINK that each key must represent one of the possible targets that I have (win32, win64, OSx). But as I just can call the value of the Key for it's name, it always return me the first key that it founds, in my case it's OS X.

1

There are 1 answers

4
Rodrigo Farias Rezino On

I'll not accept my answer as correct, it's just an option. I didn't found a possibility to do it direct in OTA so I looked for it on the registry:

procedure GetLibraryPath(Paths: TStrings; PlatformName: string);
var
  Svcs: IOTAServices;
  Options: IOTAEnvironmentOptions;
  Text: string;
  List: TStrings;
  ValueCompiler: string;
  RegRead: TRegistry;
begin
  Svcs := BorlandIDEServices as IOTAServices;
  if not Assigned(Svcs) then Exit;
  Options := Svcs.GetEnvironmentOptions;
  if not Assigned(Options) then Exit;

  ValueCompiler := Svcs.GetBaseRegistryKey;

  RegRead := TRegistry.Create;
  List := TStringList.Create;
  try
    if PlatformName = '' then
      Text := Options.GetOptionValue('LibraryPath')
    else
    begin
      RegRead.RootKey := HKEY_CURRENT_USER;
      RegRead.OpenKey(ValueCompiler + '\Library\' + PlatformName, False);
      Text := RegRead.GetDataAsString('Search Path');
    end;

    List.Text := StringReplace(Text, ';', #13#10, [rfReplaceAll]);
    Paths.AddStrings(List);

    if PlatformName = '' then
      Text := Options.GetOptionValue('BrowsingPath')
    else
    begin
      RegRead.RootKey := HKEY_CURRENT_USER;
      RegRead.OpenKey(ValueCompiler + '\Library\' + PlatformName, False);
      Text := RegRead.GetDataAsString('Browsing Path');
    end;

    List.Text := StringReplace(Text, ';', #13#10, [rfReplaceAll]);
    Paths.AddStrings(List);
  finally
    RegRead.Free;
    List.Free;
  end;
end;