Export (0) Print
Expand All
4 out of 4 rated this helpful - Rate this topic

SHSetValue function

Sets the value of a registry key.

Syntax


LSTATUS SHSetValue(
  _In_      HKEY hkey,
  _In_opt_  LPCTSTR pszSubKey,
  _In_opt_  LPCTSTR pszValue,
  _In_      DWORD dwType,
  _In_opt_  LPCVOID pvData,
  _In_      DWORD cbData
);

Parameters

hkey [in]

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

pszSubKey [in, optional]

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.

pszValue [in, optional]

Type: LPCTSTR

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

dwType [in]

Type: DWORD

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

pvData [in, optional]

Type: LPCVOID

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

cbData [in]

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.

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 4.71 or later)

Unicode and ANSI names

SHSetValueW (Unicode) and SHSetValueA (ANSI)

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.