Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search for a file at locations specified in the project Search Path?

Status
Not open for further replies.

webRAD

Programmer
Oct 13, 2002
8
AU
I am using delphi 6 prof. I am having a library of components stored in a directory and I am also having a text file stored in that directory. I can use these components from any project provided I have correctly specified the search path.

Now the problem is that in a project I want to read the text file stored in the components directory. I don’t want to use absolute or relative path to access that file but instead I want to search for the file in the directories specified in the project search path. Is it possible to retrieve the project search path?
Any example code will be of great help?

Thanks in advance.
 
This seems to be an odd thing to want to do. Do you want to access the text file at run time from the library where you have components which are used at compile time? If you do this then your application won't be very portable as it will require the Delphi IDE to be installed on the user's computer.

The Search Path information is held in the Windows Registry. Take a look at
Code:
HKEY_CURRENT_USER\Software\Borland\Delphi\n.0\Library\Search Path
where n.0 is the Delphi version number. I don't have 6.0 but it is correct for 5.0 and 7.0.

The Search Path information refers to $(DELPHI) which is the Delphi root directory. The actual location of the Delphi root directory can be found in the registry setting
Code:
HKEY_CURRENT_USER\Software\Borland\Delphi\n.0\RootDir
I assume you know how to use the TRegistry component to get at these values.

Andrew
 
Thanks for your reply,
This is true that it requires Delphi IDE to be installed at user's computer. Actually all this is happening at design time. To know more about the project I am working on please visit
What I want to do is to get all the paths specified in the project search path (Menu: Project| Options…|Directories/Conditionals tab.). There must be way to do this as this is how delphi works. For example:

unit someUnit;

interface

uses
theFile;
...
...

Delphi will look for theFile in all the directories specified in the project search path.

I want to do something similar.

Thanks once again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top