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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New FAQ: INI Files in Delphi 2

Status
Not open for further replies.
I happened to look at this just now and thought I'd point out that the constructor for TIniFile requires an exact path to the INI file. This is different than most procedures/functions that will take a relative path.

For example, if MyFileIni.ini is in the same folder as your executable you can't do I:= TIniFile.Create('MyIniFile.ini');. You have to resolve the relative path to a full and explicit path. When there are cases like this, I use a small little function like this:

Code:
function GetHomeDirectory: string;
  begin
    Result := ExtractFilePath(Paramstr(0));
  end;

I think this issue can come up on a few other kinds of things, but I thought I should point this out.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
I decided to play with interfaces and wrote an interface around the TIniFile so that I didn't have to free it when I was done. That also allowed me to do things like what Glenn pointed out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top