* * *

Author Topic: writing to registrycauses runtime errors & excepitions  (Read 1485 times)

sunpascal

  • Newbie
  • Posts: 2
writing to registrycauses runtime errors & excepitions
« on: September 13, 2005, 03:56:01 am »
hey,

I'm having trouble writing to the registry in lazarus on win xp. I
keep getting execeptions.

procedure TForm1.Button1Click(Sender: TObject);
var reg: TRegistry;

begin
  reg := TRegistry.Create;
  reg.RootKey := HKEY_CURRENT_USER;
  reg.OpenKey('test', true);
  ShowMessage(reg.ReadString('name')); // this gives me an registry ex
ception. Why?
  reg.Free;
end;

can anyone help me?
what am I doing wrong?

sunpascal

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2626
    • My Lazarus wiki user page
RE: writing to registrycauses runtime errors & excepitio
« Reply #1 on: September 13, 2005, 09:27:26 am »
First: As far as I can see, you are not writing, but reading.
Second: If you try to read a non-existing valuename, then a exception occurs. This has been fixed in fpc in  revision 1051, Sun Sep 4 17:44:33 2005 UTC.

sunpascal

  • Newbie
  • Posts: 2
RE: writing to registrycauses runtime errors & excepitio
« Reply #2 on: September 15, 2005, 05:16:27 am »
thanks for your reply.
sorry, I wasn't very specific. I get the errors when reading and writing.
I also made sure that the value existed before trying this.
However I will update.

-sunpascal

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads