INtime SDK Help
RtRegSetValueEx
INtime SDK v7.1 > About INtime > INtime Kernel > Registry access > RtRegSetValueEx

Sets the data and type of a specified value under a registry key.

Value lengths are limited by available memory. Long values (more than 2048 bytes) should be stored as files with the filenames stored in the registry. This helps the registry perform efficiently. Application elements such as icons, bitmaps, and executable files should be stored as files and not be placed in the registry.

The key identified by the hKey parameter must have been opened with KEY_SET_VALUE access. To open the key, use RtRegCreateKeyEx or RtRegOpenKeyEx.

If dwType is the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type and the ANSI version of this call is used (either by explicitly calling RtRegSetValueEx or by not defining UNICODE before including the RTBASE.H file), the data pointed to by the lpData parameter must be an ANSI character string. The string is converted to Unicode before it is stored in the registry.

LONG RtRegSetValueEx(
    HKEY hKey,           // handle to key to set value for
    LPCTSTR lpValueName, // name of the value to set
    DWORD Reserved,      // reserved
    DWORD dwType,        // flag for value type
    CONST BYTE *lpData,  // address of value data
    DWORD cbData         // size of value data
);

Parameters

hKey
Handle to a currently open key or any of the following predefined reserved handle values:

HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
HKEY_PERFORMANCE_DATA
lpValueName
Pointer to a string that contains the name of the value to set. If a value with this name is not already present in the key, the call adds it to the key.

If lpValueName is NULL or an empty string, "", the call sets the type and data for the key's unnamed or default value.

Registry keys do not have default values, but they can have one unnamed value, which can be of any type.

Reserved
Reserved; must be zero.
dwType
Specifies the type of information to be stored as the value's data. This parameter can be one of the following values:
REG_BINARY Binary data in any form.
REG_DWORD A 32-bit number.
REG_DWORD_LITTLE_ENDIAN A 32-bit number in little-endian format. This is equivalent to REG_DWORD.
REG_DWORD_BIG_ENDIAN A 32-bit number in big-endian format.
REG_EXPAND_SZ A null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%"). It is either a Unicode or ANSI string depending on whether you use the Unicode or ANSI calls.
REG_LINK A Unicode symbolic link.
REG_MULTI_SZ An array of null-terminated strings, terminated by two null characters.
REG_NONE No defined value type.
REG_RESOURCE_LIST A device-driver resource list.
REG_SZ A null-terminated string. It is either a Unicode or ANSI string depending on whether you use the Unicode or ANSI calls.

Do not use the REG_SZ type to store hard-coded paths to the system root directory or to the drive that contains the system files. Instead, use the REG_EXPAND_SZ type with environment variables such as "%SystemRoot%". This ensures that the path is up-to-date even if the user remaps the system drive to a different drive letter.

lpData
Pointer to a buffer that contains the data to be stored with the specified value name.
cbData
Specifies the size, in bytes, of the information pointed to by the lpData parameter. If the data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of the terminating null character.

Return Values

ERROR_SUCCESS
Success.
A nonzero status code defined in RTWIN32.H.
Failure.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/rtbase.h rt.h rt.lib

See Also

Registry system calls, RtRegCreateKeyEx, RtRegOpenKeyEx, RtRegFlushKey, RtRegQueryValueEx