ReadVariantDef(ValueName: String; DefaultValue: Variant): Variant;
ValueName. Name of the parameter, which value must be obtained.
DefaultValue. Value that is used if parameter does not exist.
The ReadVariantDef method reads value in the Variant format from string parameter in the registry.
If the parameter with the ValueName name does not exist, the method returns DefaultValue.
Add a link to the Registry system assembly.
Sub Main;
Var
RegKey, SubKey: IRegistryKey;
v: Variant;
Begin
RegKey := RegistryClass.CurrentUser;
SubKey := RegKey.OpenSubKey("Software\MyProject\Params", False);
v := SubKey.ReadVariantDef("Param1", "Not found");
End Sub Main;
After executing the example the value is read into the "v" variable from the parameter with the Param1 name located in the registry subkey [HKEY_CURRENT_USER\Software\MyProject\Params]. If the parameter does not exist, the Not Found value is set to the variable.
See also: