A: The documentation surrounding TRegIniFile is somewhat sparse. It is intended to work with 32 bit apps very much like TIniFile worked with 16 bit apps. The example below works as follows:
button1: Pressing this button will show how to get the keys contained within a specified group (in this case, the debugging section). Included in this is an example of retrieving the value of one of those keys (in this case, IntegratedDebugging with a default value of 666). The results are displayed in ListBox1.
button2: This one shows how to change an existing registry key value to a new one.
Note the use of the try...except blocks. This is always good
programming practice when dynamic memory allocaiton is used.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
registry, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
reg: TRegIniFile;
section: TStringList;
begin
reg := TRegIniFile.create('software\borland\delphi\2.0');
try
section := TStringList.create;
try
reg.ReadSection('debugging', section);
// This will read the entire section
listbox1.items.assign(section);
// This will read the assiciated value
for one part of the section.
listbox1.Items.add(reg.ReadString('debugging',
'IntegratedDebugging', '666'));
finally
section.free;
end;
finally
reg.free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
reg: TRegIniFile;
begin
reg := TRegIniFile.create('software\borland\delphi\2.0');
try
reg.WriteString('debugging', 'IntegratedDebugging',
'666');
finally
reg.free;
end;
end;
end.