Sets the value for a key and value name in the system registry. If the key or value name does not exist, RegistrySet creates a new key or name and sets its value.
RegistrySet ( key, valuename, valuetype, value )
Argument |
Description |
---|---|
key |
A string whose value names the key in the system registry whose value you want to set. To uniquely identify a key, specify the list of parent keys above it in the hierarchy, starting with the root key. The keys in the list are separated by backslashes. If key does not exist in the registry, RegistrySet creates a new key. To create a key without a named value, specify an empty string for valuename. |
valuename |
A string containing the name of a value in the registry. Each key may have several named values. To specify the unnamed value, specify an empty string. If valuename does not exist in the registry, RegistrySet causes a new name to be created for key. |
valuetype |
A value of the RegistryValueType enumerated datatype identifying the datatype of a value in the registry. Values are:
|
value |
A variable corresponding to the datatype of valuetype containing a value to be set in the registry. |
Integer. Returns 1 if it succeeds and -1 if an error occurs. An error is returned if the datatype of valuevariable does not correspond to the datatype specified in valuetype.
Long string values (more than 2048 bytes) should be stored as files and the file name stored in the registry.
Item |
Description |
---|---|
Key |
An element in the registry. A key is part of a tree of keys, descending from one of the predefined root keys. Each key is a subkey or child of the parent key above it in the hierarchy. There are four root strings:
A key is uniquely identified by the list of parent keys above it. The keys in the list are separated by slashes, as shown in these examples: HKEY_CLASSES_ROOT\Sybase.Application
HKEY_USERS\MyApp\Display\Fonts
|
Value name |
The name of a value belonging to the key. A key can have one unnamed value and one or more named values. |
Value type |
A value identifying the datatype of a value in the registry. |
Value |
A value associated with a value name or an unnamed value. Several string, numeric, and binary datatypes are supported by the registry. |
This example sets a value for the key Fonts and the value name Title:
RegistrySet( &
"HKEY_LOCAL_MACHINE\Software\MyApp\Fonts", &
"Title", RegString!, sle_font.Text)
This statement sets a value for the key Fonts and the value name NameOfEntryNum:
ulong ul_num
RegistrySet( &
"HKEY_USERS\MyApp.Settings\Fonts", &
"NameOfEntryNum", RegULong!, ul_num)