Difference between revisions of "fcl-registry/es"
From Lazarus wiki
Jump to navigationJump to searchLine 5: | Line 5: | ||
Name/value: the actual name/value pairs in the Key "directory". Each key can have a default value, whose name is '' (an empty string. | Name/value: the actual name/value pairs in the Key "directory". Each key can have a default value, whose name is '' (an empty string. | ||
+ | |||
+ | == Example == | ||
+ | Example that tries to get a value: | ||
+ | <syntaxhighlight> | ||
+ | uses ... registry... | ||
+ | |||
+ | var | ||
+ | CompileCommand: string=''; | ||
+ | Registry: TRegistry; | ||
+ | begin | ||
+ | Registry := TRegistry.Create; | ||
+ | try | ||
+ | // Navigate to proper "directory": | ||
+ | Registry.RootKey := HKEY_LOCAL_MACHINE; | ||
+ | if Registry.OpenKeyReadOnly('\SOFTWARE\Classes\InnoSetupScriptFile\shell\Compile\Command') then | ||
+ | CompileCommand:=Registry.ReadString(''); //read the value of the default name | ||
+ | finally | ||
+ | Registry.Free; | ||
+ | end; | ||
+ | end; | ||
+ | </syntaxhighlight> |
Revision as of 19:22, 12 March 2014
Registry terms
RootKey: registry hive where you want to start accessing the registry. Examples: HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER
Key: the path to the "directory" that contains individual data. This is a bit counter-intuitive but a holdover from compatibility with earlier versions of the registry.
Name/value: the actual name/value pairs in the Key "directory". Each key can have a default value, whose name is (an empty string.
Example
Example that tries to get a value:
uses ... registry...
var
CompileCommand: string='';
Registry: TRegistry;
begin
Registry := TRegistry.Create;
try
// Navigate to proper "directory":
Registry.RootKey := HKEY_LOCAL_MACHINE;
if Registry.OpenKeyReadOnly('\SOFTWARE\Classes\InnoSetupScriptFile\shell\Compile\Command') then
CompileCommand:=Registry.ReadString(''); //read the value of the default name
finally
Registry.Free;
end;
end;