RegSetValueEx

RegSetValueEx sets the data for the specified value in the specified registry key.

Syntax

LONG RegSetValueEx(
    HKEY           hKey,
    LPCTSTR                  lpValueName,
    DWORD          Reserved, 
    DWORD          dwType, 
    const BYTE     *lpData, 
    DWORD          cbData 
  );

Parameters

hKey

A handle to an open registry key. The key must have been opened with the KEY_SET_VALUE access right. This handle is returned by the RegCreateKey, RegCreateKeyEx, RegOpenKey or RegOpenKeyEx function. It can also be one of the following predefined keys:

HKEY_LOCAL_MACHINE

HKEY_USERS

lpValueName

The name of the value to be set. If a value with this name is not already present in the key, the function adds it to the key.

This parameter is optional. If lpValueName is NULL or an empty string, "", the function 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

This parameter is reserved and must be zero.

dwType

Type of data pointed by the lpData parameter.

lpData

Data to be stored with the specified value name. For string-based types, such as REG_SZ, the string must be null-terminated. With the REG_MULTI_SZ data type, the string must be terminated with two null characters. This parameter is optional.

cbData

Size of the information pointed to by the lpData parameter, in bytes. If the data type is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of the terminating null character or characters.

Return Value

If the function succeeds, the return value is ERROR_SUCCESS, if the function fails the return value is a nonzero error code.

Remarks

Value sizes are limited by available memory. Long values (more than 2048 bytes) should be stored as files with the file names 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.

Requirements

Minimum Supported Version RTX64 2013
Header windows.h
Library Rtx_Rtss.lib

See Also:

Registry API  

RegCreateKeyEx

RegOpenKeyEx

RegQueryValueEx