IRegistryKey.WriteVariant

Syntax

WriteVariant(ValueName: String; Value: Variant);

Parameters

ValueName. Name of the parameter, which value should be changed.

Value. Value that should be set for parameter in the registry.

Description

The WriteVariant method changes value of the parameter of the Variant type.

Comments

As a value of the Value parameter, one can send only simple type data (String, Integer, and so on).

If the parameter or subkey do 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.

Example

Executing the example requires that the registry contains a parameter named Param1 located in the subkey [HKEY_CURRENT_USER\Software\MyProject\Params].

Add a link to the Registry system assembly.

Sub UserProc;
Var
    RegKey, SubKey: IRegistryKey;
Begin
    
// Get subkey with user settings
    RegKey := RegistryClass.CurrentUser;
    SubKey := RegKey.OpenSubKey(
"Software\MyProject\Params"True);
    
// Set string value for parameter
    SubKey.WriteVariant("Param1""Changed:" + DateTime.Now.ToString);
End Sub UserProc;

After executing the example the parameter named Param1 located in the subkey [HKEY_CURRENT_USER\Software\MyProject\Params] is set to the string value "Changed: <the current date and time>".

See also:

IRegistryKey