Title: Use registry instead of *.ini file
Ini files are necessary for a storage of an information and parameters of the programs. It is possible to do it with use a registry.
This example create HKEY_LOCAL_MACHINE\Greatis Software\Example key with "First page" parameter, which stores a path to rtf file. This file will be loading from this parameter after Button2 click event.
You can store boolean, time and others types of variables in registry also.
uses Registry;
...
procedure TForm1.Button1Click(Sender: TObject);
begin
with TRegistry.Create do
begin
LazyWrite:=False;
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Greatis Software\Example', True) then
WriteString('First page', 'c:\overview.rtf')
else
MessageDlg('Registry reading error', mtError, [mbOk], 0);
CloseKey;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with TRegistry.Create do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Greatis Software\Example', False) then
try
RichEdit1.Lines.LoadFromFile(ReadString('First page'));
except
MessageDlg('Can not go to handle', mtError, [mbOk], 0);
end
else
MessageDlg('Registry reading error', mtError, [mbOk], 0);
CloseKey;
end;
end;