Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[Settings]
Width=200
Height=100
Left=0
Top=0
Background=1
[Files]
Background=C:\SomeFile.jpg
OkButton=C:\OKButtonFile.jpg
CancelButton=C:\CancelButtonFile.jpg
procedure TForm1.Button1Click(Sender: TObject);
var
I: TIniFile;
S: String;
D: TDateTime;
begin
S:= 'Hello World!';
D:= Now;
I:= TIniFile.Create('C:\MyIniFile.ini');
try
I.WriteString('MySection', 'MyString', S);
I.WriteDateTime('MySection', 'DateTime', D);
finally
I.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
I: TIniFile;
S: String;
D: TDateTime;
begin
I:= TIniFile.Create('C:\MyIniFile.ini');
try
S:= I.ReadString('MySection', 'MyString', 'Default Value');
D:= I.ReadDateTime('MySection', 'DateTime', Now);
finally
I.Free;
end;
end;
[Settings]
SomeProp=Yes
AnotherProp=No
[Item:0]
Name=This is Item 0
Val1=1
Val2=2
[Item:1]
Name=This is Item 1
Val1=3
Val2=4
[Item:2]
Val1=5
Val2=6
procedure TForm1.Button3Click(Sender: TObject);
var
I: TIniFile;
L: TStringList;
X: Integer;
S: String;
Z: Integer;
T: String;
begin
I:= TIniFile.Create('C:\MyIniFile.ini');
try
L:= TStringList.Create;
try
I.ReadSections(L);
for X:= 0 to L.Count - 1 do begin
S:= LowerCase(L[X]);
if Pos('item:', S) = 1 then begin
T:= S;
Delete(T, 1, 5); //Length of 'item:'
Z:= StrToIntDef(T, 0); //True index of item
ListBox1.Items.Append('Item '+IntToStr(Z)+': '+I.ReadString(S, 'Name', '(No Name)'));
end;
end;
finally
L.Free;
end;
finally
I.Free;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
I: TIniFile;
L: TStringList;
X: Integer;
S: String;
Z: Integer;
T: String;
begin
I:= TIniFile.Create('C:\MyIniFile.ini');
try
L:= TStringList.Create;
try
I.ReadSectionValues('MySection', L);
for X:= 0 to L.Count - 1 do begin
S:= LowerCase(L[X]);
if Pos('item:', S) = 1 then begin
T:= S;
Delete(T, 1, 5); //Length of 'item:'
Z:= StrToIntDef(T, 0); //True index of item
ListBox1.Items.Append('Item '+IntToStr(X)+': '+I.ReadString('MySection', S, '(No Name)'));
end;
end;
finally
L.Free;
end;
finally
I.Free;
end;
end;
type
TMyIniFile = class(TObject)
private
FFilename: String;
FActive: Bool;
FIni: TIniFile;
function GetMyString: String;
function GetMyInteger: Integer;
procedure SetMyString(const Value: String);
procedure SetMyInteger(const Value: Integer);
public
constructor Create(const Filename: String);
destructor Destroy; override;
published
property MyString: String read GetMyString write SetMyString;
property MyInteger: Integer read GetMyInteger write SetMyInteger;
end;
implementation
constructor TMyIniFile.Create(const Filename: String);
begin
FActive:= False;
FFilename:= AFilename;
try
FIni:= TIniFile.Create(FFilename);
FActive:= True;
except
on e: exception do begin
FIni.Free;
end;
end;
end;
destructor TMyIniFile.Destroy;
begin
if FActive then
FIni.Free;
inherited;
end;
function TMyIniFile.GetMyString: String;
begin
if FActive then
Result:= FIni.ReadString('MySection', 'MyString', '')
else
Result:= '';
end;
function TMyIniFile.GetMyInteger: Integer;
begin
if FActive then
Result:= FIni.ReadInteger('MySection', 'MyInteger', 0)
else
Result:= 0;
end;
procedure TMyIniFile.SetMyString(const Value: String);
begin
if FActive then
FIni.WriteString('MySection', 'MyString', Value);
end;
procedure TMyIniFile.SetMyInteger(const Value: Integer);
begin
if FActive then
FIni.WriteInteger('MySection', 'MyInteger', Value);
end;