RegSetKeyValue

 

Description

 

Sets the data for the specified value in the specified registry key and subkey.

 

C++ Syntax

 

LONG WINAPI RegSetKeyValue(

__in     HKEY hKey,

__in_opt LPCTSTR lpSubKey,

__in_opt LPCTSTR lpValueName,

__in     DWORD dwType,

__in_opt LPCVOID lpData,

__in     DWORD cbData

);

 

PowerBASIC Syntax

 

FUNCTION RegSetKeyValue ( _

BYVAL hKey AS DWORD, _

BYREF lpSubKey AS ASCIIZ, _

BYREF lpValueName AS ASCIIZ, _

BYVAL dwType AS DWORD, _

BYREF lpData AS ANY, _

BYVAL cbData AS DWORD _

) AS LONG

 

Unicode version:

 

FUNCTION RegSetKeyValueW ( _

BYVAL hKey AS DWORD, _

BYVAL lpSubKey AS DWORD, _

BYVAL lpValueName AS DWORD, _

BYVAL dwType AS DWORD, _

BYREF lpData AS ANY, _

BYVAL cbData AS DWORD _

) AS LONG

 

Parameters

 

hKey

 

[in] 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 RegCreateKeyEx, RegCreateKeyTransacted, RegOpenKeyEx, or RegOpenKeyTransacted function. It can also be one of the following predefined keys:

 

HKEY_CLASSES_ROOT

HKEY_CURRENT_CONFIG

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_USERS

 

lpSubKey

 

[in, optional] The name of a key. This key must be a subkey of the key identified by the hKey parameter.

 

lpValueName

 

[in, optional] The name of the registry value whose data is to be updated.

 

dwType

 

[in] The type of data pointed to by the lpData parameter. For a list of the possible types, see Registry Value Types.

 

lpData

 

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

 

cbData

 

[in] The size of the information pointed to by the lpData parameter, in bytes. 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 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 defined in Winerror.inc. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

 

Valid XHTML 1.0 Transitional