home *** CD-ROM | disk | FTP | other *** search
- unit IDELibPath;
- // from GX_experts Backup.pas
- interface
- uses classes;
-
- Function GetIdeLibraryPath(version : string = '5') : tstringlist;
-
- implementation
- Uses sysutils, FileCtrl, registry, Windows, controls, dialogs, fExtractLibPath;
- //, ToolIntf, ExptIntf, ToolsApi;
-
- Function GetIdeLibraryPath(version : string = '5') : tstringlist;
- const
- LibrarySection = '\Library';
- {$IFDEF VER100}
- LibraryPathValue = 'SearchPath';
- {$ELSE}
- LibraryPathValue = 'Search Path';
- {$ENDIF VER100}
-
- IdeBase = '$(DELPHI)';
-
-
- var
- BasePath: string;
-
- procedure AddPathItemToList(PathItem: string);
- var
- IdeBasePos: Integer;
- begin
- PathItem := UpperCase(PathItem);
-
- // Expand the folder name if necessary $(DELPHI); $(BCB), VER110 and up
- IdeBasePos := Pos(IdeBase, PathItem);
- if IdeBasePos > 0 then
- begin
- Delete(PathItem, IdeBasePos, Length(IdeBase));
- Insert(BasePath, PathItem, IdeBasePos);
- end;
- // Make sure that every item has a trailing slash.
- // This simplifies processing when we scan for files.
- // not needed as we just want a list to pass to the compiler via -U
- // PathItem := AddSlash(PathItem);
-
- // verify that the directory exists
- if DirectoryExists(PathItem) then
- begin
- // Result.add(ExtractShortPathName(PathItem));
- Result.add(PathItem);
- {if pos(' ', pathitem) > 0
- then Result.Add('"'+PathItem+'"')
- else Result.add(PathItem);
- }
- end;
- end;
-
- var
- PathString: string;
- PathItem: string;
- CPos: Integer;
- pathname : string;
- begin
- with tf_ExtractLibPath.create(nil) do begin
- edit1.text := version;
- if ShowModal = mrOK
- then begin
- version := edit1.text;
- if not ((version = '5') or (version = '4'))
- then begin
- ShowMessage('Only 4 and 5 supported at this time for automated library path extraction');
- free;
- exit;
- end;
- end
- else begin
- free;
- exit;
- end;
- free;
- end;
-
- result := tstringlist.create;
- {$Ifdef VER130}
- pathname := '\Software\Borland\Delphi\'+version+'.0';
- {$ENDIF}
- {$Ifdef VER120}
- pathname := '\Software\Borland\Delphi\'+version+'.0';
- {$ENDIF}
-
- with TRegistry.Create do
- try
- //if OpenKey(ToolServices.GetBaseRegistryKey + LibrarySection, False)
- if OpenKey(pathname + LibrarySection, False)
- then begin
- PathString := ReadString(LibraryPathValue);
- CloseKey;
- end;
-
- RootKey := HKEY_LOCAL_MACHINE;
- // if OpenKey(ToolServices.GetBaseRegistryKey, False)
- if OpenKey(pathname, False)
- then begin
- BasePath := ReadString('RootDir');
- CloseKey;
- end;
- finally
- Free;
- end;
-
- CPos := Pos(';', PathString);
- while CPos > 0 do
- begin
- PathItem := Trim(Copy(PathString, 1, CPos-1));
- if PathItem <> '' then
- AddPathItemToList(PathItem);
-
- Delete(PathString, 1, CPos);
- CPos := Pos(';', PathString);
- end;
- PathString := Trim(PathString);
- if PathString <> '' then
- AddPathItemToList(PathItem);
- end;
-
-
- end.
-