Delphi: save registry keys: what's wrong with this code?


[ Related Articles and Replies ] [ DelphiLand Discussion Forum ]

Posted by P12160 Stefan Loeners on November 28, 2002 at 15:30:26:

I am trying to save a registry key in Delphi, with all subkeys and values to a file. The file is created but it is empty. I use Delphi 5 Enterprise and NT4.
Thank you.

procedure TForm1.Button1Click(Sender: TObject);
const
  sFileName:string = 'c:\temp\_regsaveok';
  sRegString:string= '\Software\ABBYY';
var
  Form1: TForm1;
  Registry1:TRegistry;
begin
  // delete file if it exists (SaveKey will NOT work if file exists !!!)
  if FileExists(sFilename) then deletefile(sFilename);
  Registry1 := TRegistry.create;
  With Registry1 do begin
    RootKey:= HKEY_LOCAL_MACHINE;
    if SaveKey(sRegString,sFilename) = false then showmessage('NOT ok');
    free;
  end;
end;

Related Articles and Replies:


 

[ DelphiLand Discussion Forum ]