Skip to content

Latest commit

 

History

History
135 lines (96 loc) · 4.89 KB

nf-winreg-regsetkeyvaluew.md

File metadata and controls

135 lines (96 loc) · 4.89 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winreg.RegSetKeyValueW
RegSetKeyValueW function (winreg.h)
Sets the data for the specified value in the specified registry key and subkey. (Unicode)
RegSetKeyValue
RegSetKeyValue function
RegSetKeyValueW
base.regsetkeyvalue
winreg/RegSetKeyValue
winreg/RegSetKeyValueW
base\regsetkeyvalue.htm
winprog
e27d2dd6-b139-4ac1-8dd8-527022333364
12/05/2018
RegSetKeyValue, RegSetKeyValue function, RegSetKeyValueA, RegSetKeyValueW, base.regsetkeyvalue, winreg/RegSetKeyValue, winreg/RegSetKeyValueA, winreg/RegSetKeyValueW
winreg.h
Windows.h
Windows
Windows Vista [desktop apps only]
Windows Server 2008 [desktop apps only]
RegSetKeyValueW (Unicode) and RegSetKeyValueA (ANSI)
Advapi32.lib
Advapi32.dll
Windows
19H1
RegSetKeyValueW
winreg/RegSetKeyValueW
c++
APIRef
kbSyntax
DllExport
Advapi32.dll
API-MS-Win-Core-Registry-l2-1-0.dll
advapi32legacy.dll
API-MS-Win-Core-Registry-l1-1-1.dll
KernelBase.dll
MinKernelBase.dll
RegSetKeyValue
RegSetKeyValueA
RegSetKeyValueW

RegSetKeyValueW function

-description

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

-parameters

-param hKey [in]

A handle to an open registry key. The key must have been opened with the KEY_SET_VALUE access right. For more information, see Registry Key Security and Access Rights.

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

-param lpSubKey [in, optional]

The name of the subkey relative to the key identified by hKey. If the subkey does not exist, it is created as a non-volatile key with a default security descriptor. If this parameter is NULL, then the value is created in the key specified by hKey.

-param lpValueName [in, optional]

The name of the registry value whose data is to be updated.

-param dwType [in]

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

-param 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.

-param 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.

-returns

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.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

-remarks

To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later. For more information, see Using the Windows Headers.

Note

The winreg.h header defines RegSetKeyValue 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.

-see-also

RegDeleteKeyValue

Registry Functions