function SetIniBool(
const Section, Key:
String;
const Value: Boolean;
const Filename:
String): Boolean;
function SetIniInt(
const Section, Key:
String;
const Value: Longint;
const Filename:
String): Boolean;
function SetIniString(
const Section, Key, Value, Filename:
String): Boolean;
Code:
[Setup]
AppName='Write to ini example';
AppVerName=0.0.0.0
CreateAppDir=false
OutputDir=".\"
[ Code ]
const
INIFILE = 'config.ini';
procedure OnChange(Sender: TObject);
begin
SetIniString(TControl(Sender).Name, 'Text', TEdit(Sender).Text, ExpandConstant('{src}\') + INIFILE);
end;
procedure OnClick(Sender: TObject);
begin
SetIniBool(TControl(Sender).Name, 'State', (Sender as TCheckBox).Checked, ExpandConstant('{src}\') + INIFILE);
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:=False
Cancel:=True
end;
procedure InitializeWizard();
begin
with WizardForm do
begin
BorderStyle := bsToolWindow;
Position := poScreenCenter;
AutoScroll := False;
ClientWidth := ScaleX(300);
ClientHeight := ScaleY(100);
Caption:={#SetupSetting("AppName")};
InnerNotebook.Hide;
OuterNotebook.Hide;
end;
with TLabel.Create(WizardForm) do
begin
Parent := WizardForm;
SetBounds(5, 8, 40, 15);
Caption:='Edit1: ';
Font.Size:=10;
end;
with TEdit.Create(WizardForm) do
begin
Parent := WizardForm;
SetBounds(50, 5, WizardForm.ClientWidth - 60, 15);
OnChange:=@OnChange;
Name:='Edit1';
end;
with TLabel.Create(WizardForm) do
begin
Parent := WizardForm;
SetBounds(5, 33, 40, 15);
Caption:='Edit2: ';
Font.Size:=10;
end;
with TEdit.Create(WizardForm) do
begin
Parent := WizardForm;
SetBounds(50, 30, WizardForm.ClientWidth - 60, 15);
OnChange:=@OnChange;
Name:='Edit2';
end;
with TCheckBox.Create(WizardForm) do
begin
Parent := WizardForm;
SetBounds(50, 70, 150, 15);
OnClick:=@OnClick;
Name:='CheckBox1';
Checked:=GetIniBool(Name, 'State', false, ExpandConstant('{src}\') + INIFILE);
end;
with TCheckBox.Create(WizardForm) do
begin
Parent := WizardForm;
SetBounds(150, 70, 150, 15);
OnClick:=@OnClick;
Name:='CheckBox2';
Checked:=GetIniBool(Name, 'State', false, ExpandConstant('{src}\') + INIFILE);
end;
end;