WriteVariant(ValueName: String; Value: Variant);
ValueName - name of the parameter, which value must be changed.
Value - value that must be set to the parameter in the registry. Only data of simple types (String, Integer, etc.), can be used as values.
The WriteVariant method changes value of the parameter of the Variant type.
Name and new value are passed by the ValueName and Value parameters respectively. If the parameter or subkey does not exist, it is created automatically. If the parameter exists, the type and value is changed according to the entered data.
If it is required to change value of the default parameter, pass empty string ("") as a name.
Sub Main;
Var
RegKey, SubKey: IRegistryKey;
Begin
RegKey := RegistryClass.CurrentUser;
SubKey := RegKey.OpenSubKey("Software\MyProject\Params", True);
SubKey.WriteVariant("Param1", "Modified:" + DateTime.Now.ToString);
End Sub Main;
After executing the example the parameter with the Param1 name located in the subkey HKEY_CURRENT_USER\Software\MyProject\Params is set to the string value Modified: <current date and time>.
See also: