Sets the value of a registry key.
Syntax
LSTATUS SHSetValue(
HKEY hkey,
LPCTSTR pszSubKey,
LPCTSTR pszValue,
DWORD dwType,
LPCVOID pvData,
DWORD cbData
);
Parameters
- hkey
-
[in] A handle to the currently open key, or any of the following predefined values.
HKEY_CLASSES_ROOTHKEY_CURRENT_CONFIGHKEY_CURRENT_USERHKEY_DYN_DATA (Microsoft Windows 95 only)HKEY_LOCAL_MACHINEHKEY_PERFORMANCE_DATA (Microsoft Windows NT only)HKEY_USERS
- pszSubKey
-
[in] 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.
- pszValue
-
[in] The address of a null-terminated string that specifies the value. This value can be NULL.
- dwType
-
[in] Type of data to be stored. This parameter must be the REG_SZ type. For more information, see Registry Data Types.
- pvData
-
[in] Pointer to a buffer that contains the data to set for the specified value. This value can be NULL.
- cbData
-
[in] 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
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.
Function Information
| Minimum DLL Version | shlwapi.dll version 4.71 or later |
|---|
| Custom Implementation | No |
|---|
| Header | shlwapi.h |
|---|
| Import library | shlwapi.lib |
|---|
| Minimum operating systems |
Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0 |
|---|
| Unicode | Implemented as
ANSI and Unicode versions. |
|---|