Writing Ini Files With Api Example code.

posted 18 Sep 2010, 15:26 by Delphi Basics   [ updated 23 Sep 2010, 19:17 ]
This example, written by Protocol, allows you to write to ini files using pure api. 

Function ReadIni(StrIniPath : pchar; StrSection : pchar; StrItem : pchar; StrDefault : pchar) : String;
var
RetAmount : Integer;
StrTemp : String;
StrRet : string;
begin
  SetLength(StrTemp,50);
  RetAmount := GetPrivateProfileString(StrSection, StrItem, StrDefault, pchar(StrTemp), 50, StrIniPath);
  StrRet := Copy(StrTemp,1,RetAmount);
  Result := StrRet;
End;

procedure WriteIni(StrIniPath : pchar; StrSection : pchar; StrItem : pchar; StrText : pchar);
begin
  WritePrivateProfileString(StrSection, StrItem, StrText, StrIniPath);
End;
Comments