function LeeDatoIni(FicheroINI: string; const Section, Ident: string; Default: string = ''): string; overload;
begin
with TIniFile.Create(FicheroINI) do
begin
try
Result := ReadString(Section, Ident, Default);
finally
Free;
end;
end;
end;
function LeeDatoIni(FicheroINI: string; const Section, Ident: string; Default: integer = 0): integer; overload;
begin
with TIniFile.Create(FicheroINI) do
begin
try
Result := ReadInteger(Section, Ident, Default);
finally
Free;
end;
end;
end;
function LeeDatoIni(FicheroINI: string; const Section, Ident: string; Default: TDateTime = 0): TDateTime; overload;
begin
if (Default = 0) then
Default := Now;
with TIniFile.Create(FicheroINI) do
begin
try
Result := ReadDateTime(Section, Ident, Default);
finally
Free;
end;
end;
end;
procedure EscribeDatoIni(FicheroINI: string; const Section, Ident, Dato: string); overload;
begin
with TIniFile.Create(FicheroINI) do
begin
try
WriteString(Section, Ident, Dato);
finally
Free;
end;
end;
end;
procedure EscribeDatoIni(FicheroINI: string; const Section, Ident: string; Dato: integer); overload;
begin
with TIniFile.Create(FicheroINI) do
begin
try
WriteInteger(Section, Ident, Dato);
finally
Free;
end;
end;
end;
procedure EscribeDatoIni(FicheroINI: string; const Section, Ident: string; Dato: TDateTime); overload;
begin
with TIniFile.Create(FicheroINI) do
begin
try
WriteDateTime(Section, Ident, Dato);
finally
Free;
end;
end;
end;
var
FicheroINI : string;
begin
FicheroINI := ChangeFileExt(ExtractFileName(Application.ExeName), '.INI');
Checkox1.Checked := (LeeDatoIni(FicheroINI, 'EstadoCheckBox', 'CheckBox1', 0) = 1);
Checkox2.Checked := (LeeDatoIni(FicheroINI, 'EstadoCheckBox', 'CheckBox2', 0) = 1);
...
if Checkox1.Checked then
EscribeDatoIni(FicheroINI, 'EstadoCheckBox', 'CheckBox1', 1)
else
EscribeDatoIni(FicheroINI, 'EstadoCheckBox', 'CheckBox1', 0);
if Checkox2.Checked then
EscribeDatoIni(FicheroINI, 'EstadoCheckBox', 'CheckBox2', 1)
else
EscribeDatoIni(FicheroINI, 'EstadoCheckBox', 'CheckBox2', 0);
end;