Index » Empathy Jukebox : Blob 790da8 / inifuncs.pas
unit inifuncs;

interface

uses sysutils,windows;

type
  tinifile = class
   private
   function writepp(s : string;n : string) : integer;
   function readpp(s : string; d: string) : string;
   protected
   public
   path : string;
   inipath : string;
   section : string;
   function writeppstring(s: String;n : string) : integer;
   function writeppbool(s: String;n : boolean) : integer;
   function writeppinteger(s : String;n : integer) : integer;
   function readppstring(s : string;d : string) : string;
   function readppinteger(s : string; d : string) : integer;
   function readppbool(s : string; d : string) : boolean;
   published
  end;

implementation

function tinifile.writepp(s : string;n : string) : integer;
begin
result:=0;
writeprivateprofilestring(pchar(section),pchar(s),pchar(n),pchar(inipath));
end;

function tinifile.writeppstring(s : String;n : string) : integer;
begin
result:=writepp(s,n);
end;

function tinifile.writeppbool(s: string;n : boolean) : integer;
begin
result:=writepp(s,inttostr(integer(n)));
end;

function tinifile.writeppinteger(s: string;n : integer) : integer;
begin
result:=writepp(s,inttostr(n));
end;

function tinifile.readpp(s : string;d : string) : string;
var
r : array[0..1024] of char;
g : integer;
begin
g:=length(r);
getprivateprofilestring(pchar(section),pchar(s),pchar(d),r,g,pchar(inipath));
result:=r;
end;

function tinifile.readppstring(s : string;d : string) : string;
var
r : string;
begin
r:=readpp(s,d);
result:=r;
end;

function tinifile.readppinteger(s : string;d : string) : integer;
var
r : string;
x : integer;
z : integer;
begin
r:=readpp(s,d);
val(r,x,z);
result:=x;
end;

function tinifile.readppbool(s : string;d : string) : boolean;
var
r : string;
x : integer;
z : integer;
begin
r:=readpp(s,d);
val(r,x,z);
result:=boolean(x);
end;

end.