I've added some code to my delphi project to interact with the registry, using some tutorials I found online to guide my effort. Every example I've seen seems to use this structure for their registry access:
var
Registry: TRegistry;
begin
try
Registry := TRegistry.Create;
//additional code to access and use the registry object could go here
finally
Registry.Free;
end;
But when I implement my code following that structure, I am getting a warning that my variable Registry may not have been initialized on the line where I free the TRegistry object.
So, I'm wondering whether the examples I've found are just wrong on the right way to access the registry. Should I be calling Free on my TRegistry object regardless of whether the Create succeeeds, and just ignore the warning? Should, instead, my try/finally block only surround the code after the successful constructor call, but not wrap the create call? Something else?