LONG RegSetValue(hkey, lpszSubKey, fdwType, lpszData, cbData) | |||||
HKEY hkey; | /* identifies key to set value for | */ | |||
LPTSTR lpszSubKey; | /* address of subkey name | */ | |||
DWORD fdwType; | /* type of value | */ | |||
LPTSTR lpszData; | /* address of value data | */ | |||
DWORD cbData; | /* size of value data | */ |
The RegSetValue function associates a text string with a specified key.
hkey
Identifies a currently open key or any of the following predefined reserved handle values:
HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS
lpszSubKey
Points to a null-terminated string specifying the name of the subkey to open. This parameter must not be NULL.
fdwType
Specifies the type of information to be stored. This parameter must be REG_SZ. Use the RegSetValueEx function to store other data types.
lpszData
Points to a null-terminated string specifying the text string to set for the given key.
cbData
Specifies the length (in bytes) of the string at lpszData.
The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.
If the key specified by the lpszSubKey parameter does not exist, the RegSetValue function creates it.
Value lengths are limited by available memory. Long values (more than 2048 bytes) should be stored as files, with the filenames stored in the configuration registry. This will help the registry perform efficiently. Application elements such as icons, bitmaps, and executable files should be stored in the file system, not in the registry.
Use the RegFlushKey function to guarantee that the changes made by the RegSetValue function are saved.
The key specified by hkey must have been opened with KEY_SET_VALUE access. Use the RegCreateKeyEx or RegOpenKeyEx function to open the key.
If the ANSI version of this function is used (either by explicitly calling RegSetValueA or by not defining UNICODE before including windows.h), lpszData must be an ANSI character string. The string is converted to Unicode before it is stored in the registry.
RegSetValueEx, RegQueryValue, RegQueryValueEx