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 );
hKey
lpValueName
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
dwType
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
cbData
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. ERROR_SUCCESS
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/rtbase.h | rt.h | rt.lib |
Registry system calls, RtRegCreateKeyEx, RtRegOpenKeyEx, RtRegFlushKey, RtRegQueryValueEx