Hi All,
With the following code I read a value in the reg. database.
procedure TfrmGraph.ReadRegistry;
var
Registry: TRegistry;
begin
try
Registry := TRegistry.Create;
Registry.RootKey := HKEY_CURRENT_USER;
Registry.OpenKey('\SOFTWARE\TCC\Settings', True);
seZAxis.Value := Registry.ReadInteger('ZAxis');
finally
Registry.Free;
end;
If my program runs for the first time the registry of course doesn't contain the key. In this case the key should be created automatically,
but despite of this I get an access violation when the program is run the first time.
The error comes with this line:
seZAxis.Value := Registry.ReadInteger('ZAxis');
I think the reason is that the new created key doesn't contain any information, but how do you normally prevent the program to crash in this case? I thought I could prevent the crash with the try - except, but it makes no difference.
Any ideas?