RegSetValueEx

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

Syntax

Copy
LONG RegSetValueEx(
    [in]             HKEY           hKey,
    [in, optional]   LPCTSTR        lpValueName,
                     DWORD          Reserved, 
    [in]             DWORD          dwType, 
    [in]             const BYTE     *lpData, 
    [in]             DWORD          cbData 
  );

Parameters

[in] 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:

[in, optional] 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.

[in] dwType

Type of data pointed by the lpData parameter.

[in] 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.

[in] 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, it returns ERROR_SUCCESS. If the function fails, it returns a non-zero 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 Header Library

wRTOS 1.0 SDK

windows.h

wRTOS_rtss.lib

See Also: