INtime SDK Help
RegSetValueEx (iwin32)
INtime SDK v7 > About INtime > Alternate APIs > iwin32 API > iwin32 API > RegSetValueEx (iwin32)

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

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

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 these 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 store with the specified value name.
cbData
Specifies the number of bytes in 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.

Remarks

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 be opened with KEY_SET_VALUE access. To open the key, use RegCreateKeyEx or RegOpenKeyEx.

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

Return Values

ERROR_SUCCESS
Success.
A nonzero status code defined in RTWIN32.H.
Failure. For extended error information, see GetLastError

Requirements

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

Note

This function operates in the real-time portion of your application.

See Also

RegCreateKeyEx, RegOpenKeyEx, RegQueryValueEx, RegSetValueEx, iwin32 API, iwin32 Overview