ReadStringDef(ValueName: String; DefaultValue: String): String;
ValueName. Name of the parameter, which value must be obtained.
DefaultValue. Value that is used if parameter does not exist.
The ReadStringDef method reads string 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 UserProc;
Var
RegKey, SubKey: IRegistryKey;
s: String;
Begin
RegKey := RegistryClass.CurrentUser;
SubKey := RegKey.OpenSubKey("Software\MyProject\Params", False);
s := SubKey.ReadStringDef("Param1", "Default");
End Sub UserProc;
After executing the example, string value is read from the parameter with the Param1 name located in the registry subkey [HKEY_CURRENT_USER\Software\MyProject\Params] into the "s" variable. If the parameter does not exist, the default value is set to the "s" variable.
See also: