|
#1
|
||||
|
||||
|
Write on an ini file
Using Inno Setup Compiler I have added a screen with the various components, I should read the content that is inserted into a textbox and write it in an ini file.
Same thing with the combobox component. I added the section Code: [Ini] Filename: {app} \ fileProva.ini; Section: prova1; Key: nomeTextBox1 Filename: {app} \ fileProva.ini; Section: Prova2; Key: nomeTextBox2 Is that okay? Or should I add something else? |
| Sponsored Links |
|
#2
|
||||
|
||||
|
function GetIniBool(const Section, Key: String; const: Boolean; const Filename: String): Boolean;
function GetIniInt(const Section, Key: String; const Default, Min, Max: Longint; const Filename: String): Longint; function GetIniString(const Section, Key, Default, Filename: String): String; Code:
Example:
var
sCaption: string;
iLeft, iTop, iWidth, iHeight: integer;
bChecked: boolean;
sCaption:=GetIniString('chkb', 'Caption', 'Component 1', ExpandConstant('{src}') + '\YourFile.ini');
iLeft:=GetIniInt('chkb', 'Left', '30', ExpandConstant('{src}') + '\YourFile.ini');
iTop:=GetIniInt('chkb', 'Top', '50', ExpandConstant('{src}') + '\YourFile.ini');
iWidth:=GetIniInt('chkb', 'Width', '150', ExpandConstant('{src}') + '\YourFile.ini');
iHeight:=GetIniInt('chkb', 'Height', '20', ExpandConstant('{src}') + '\YourFile.ini');
bChecked=GetIniBool('chkb', 'Checked', 'true', ExpandConstant('{src}') + '\YourFile.ini');
CheckBox1.Caption:=sCaption;
CheckBox1.SetBounds(iLeft, iTop, iWidth, iHeight);
CheckBox1.Checked:=bChecked;
__________________
Practice makes perfect. |
| The Following 2 Users Say Thank You to JRD! For This Useful Post: | ||
EzzEldin16 (28-08-2017), Simorq (28-08-2017) | ||
|
#3
|
||||
|
||||
|
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;
__________________
Practice makes perfect. |
| The Following 3 Users Say Thank You to JRD! For This Useful Post: | ||
|
#4
|
||||
|
||||
|
Sorry for the response delay.
Thanks for the help, I will try to figure out how it works. |
![]() |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Anno 1701 won't load, just get a blue screen! | Shadow22 | General Gaming | 5 | 28-08-2012 12:52 |
| Having a nightmare with Iomega USB ZipCD - Help! | Tranced | CD/DVD-Writers | 2 | 03-04-2005 06:00 |
| PMA Update failure....????????? | dannyk | DVD Backup Forum | 1 | 05-01-2005 14:19 |
| Flat Out Protection | t.foster73 | PC Games | 59 | 26-11-2004 01:39 |
| HELP ME PLZ!!!! | Dalvin | DC Games | 0 | 02-01-2001 22:14 |