sexta-feira, 11 de abril de 2008

Ler e gravar no Registro do Windows


//Gravar um valor
procedure TForm1.Button2Click(Sender: TObject);
var
Reg : TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey('Teste',True);
Reg.WriteString('TesteValor',edit1.Text);
finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
end;

//Ler um valor
procedure TForm1.Button1Click(Sender: TObject);
var
Reg : TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey('Teste',False);
ShowMessage(Reg.ReadString('TesteValor'));
finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
end;


  © Blogger template 'Perfection' by Ourblogtemplates.com 2008

Back to TOP