SHSetValueA function (shlwapi.h)

Sets the value of a registry key.

Syntax

LSTATUS SHSetValueA(
  [in]           HKEY    hkey,
  [in, optional] LPCSTR  pszSubKey,
  [in, optional] LPCSTR  pszValue,
  [in]           DWORD   dwType,
  [in, optional] LPCVOID pvData,
  [in]           DWORD   cbData
);

Parameters

[in] hkey

Type: HKEY

A handle to the currently open key, or any of the following predefined values.

HKEY_CLASSES_ROOT

HKEY_CURRENT_CONFIG

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_PERFORMANCE_DATA

HKEY_USERS

[in, optional] pszSubKey

Type: LPCTSTR

The address of a null-terminated string that specifies the name of the subkey with which a value is associated. This can be NULL or a pointer to an empty string. In this case, the value is added to the key identified by the hkey parameter.

[in, optional] pszValue

Type: LPCTSTR

The address of a null-terminated string that specifies the value. This value can be NULL.

[in] dwType

Type: DWORD

Type of data to be stored. This parameter must be the REG_SZ type. For more information, see Registry Data Types.

[in, optional] pvData

Type: LPCVOID

Pointer to a buffer that contains the data to set for the specified value. This value can be NULL.

[in] cbData

Type: DWORD

Length, in bytes, of the buffer pointed to by the pvData parameter. If the data is a null-terminated string, this length includes the terminating null character.

Return value

Type: LSTATUS

Returns ERROR_SUCCESS if successful; otherwise, a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to retrieve a generic description of the error.

Remarks

Note

The shlwapi.h header defines SHSetValue as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlwapi.h
Library Shlwapi.lib
DLL Shlwapi.dll (version 4.71 or later)