Access Registry
To access registry, you should add Registry in your USES clause. Then remember to specify False in OpenKey() method to read values, and True to write values. So simple, isn't it??
Here is the sample source code:
procedure ReadRegistry;
var
regEntry : TRegistry;
begin
// Create an instance of TRegistry
regEntry := TRegistry.Create;
try
regEntry.RootKey := HKEY_CURRENT_USER;
try
if regEntry.OpenKey( 'Software\Hianoto', False ) then begin
nInteger := regEntry.ReadInteger( 'Integer' );
regEntry.CloseKey;
end;
except
// Error Handler
end;
finally
// Destroy the instance
regEntry.Free;
end;
end;
procedure WriteRegistry;
var
regEntry : TRegistry;
begin
// Create an instance of TRegistry
regEntry := TRegistry.Create;
try
regEntry.RootKey := HKEY_CURRENT_USER;
try
if regEntry.OpenKey( 'Software\Hianoto', True ) then begin
regEntry.WriteInteger( 'Integer', 1 );
regEntry.WriteString( 'String', 'Hian' );
regEntry.CloseKey;
end;
except
// Error Handler
end;
finally
regEntry.Free;
end;
end;
I currently live happily with my beloved family in Semarang. I am an IT-addict, but have huge interests on Internet Marketing, Family Financial Planning, Personal Wealth Building, and other self development activities. Beside that, I also like to read books, eat delicious foods, and play games with my beloved son.
