RegistryKey: SetValue

SetValue

Sets the value of a key value within the SubKey.



 Public Sub SetValue(
	  ByRef Name As String,
	  ByRef Value As Variant,
	  Optional ByVal ValueKind As RegistryValueKind = UnknownKind )

Parameters

Name
[ByRef] String. The name of the value to set, or an empty string to set the key default value.
Value
[ByRef] Variant. The value to write to the Registry.
ValueKind
[ByVal] Optional. RegistryValueKind. The type of value to be written to the registry.  

Default: UnknownKind

Remarks

The registry can hold several types of data. RegistryKey supports many data types.
REG_DWORD (Integer numbers)
REG_QWORD (64-bit integer)
REG_BINARY (Byte arrays)
REG_SZ (Strings)
REG_MULTI_SZ (String arrays)
REG_EXPAND_SZ (Expandable string)

Another value type is any class that implements the cObject interface. The ToString method is used to write the string representation to the Registry. This makes it easy to write such values as cDateTime with ease.

If saving as a REG_QWORD then numeric values passed in may be adjusted to and mapped to an internal vbCurrency datatype to represent the 64-bit value accurately in the registry. If a vbLong value of 1 is passed in, then it will be set to a vbCurrency value of 0.0001. This will give the proper bit alignment with the 64-bit registry value. In order to avoid having the value mapped to a vbCurrency, pass the value in as a vbCurrency. In this case, the value is not changed and the 64-bits are saved to the registry as is. A vbCurrency of 1 will be saved to the registry as is, not as 0.0001.

See Also

Project CorLib Overview

Class RegistryKey Overview