Exportar (0) Imprimir
Expandir todo
EN
Este contenido no se encuentra disponible en su idioma, pero aquí tiene la versión en inglés.

RegSetValue function

Sets the data for the default or unnamed value of a specified registry key. The data must be a text string.

Note  This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the RegSetValueEx function.

Syntax


LONG WINAPI RegSetValue(
  _In_      HKEY hKey,
  _In_opt_  LPCTSTR lpSubKey,
  _In_      DWORD dwType,
  _In_      LPCTSTR lpData,
  _In_      DWORD cbData
);

Parameters

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

The name of a subkey of the hKey parameter. The function sets the default value of the specified subkey. If lpSubKey does not exist, the function creates it.

Key names are not case sensitive.

If this parameter is NULL or points to an empty string, the function sets the default value of the key identified by hKey.

For more information, see Registry Element Size Limits.

dwType [in]

The type of information to be stored. This parameter must be the REG_SZ type. To store other data types, use the RegSetValueEx function.

lpData [in]

The data to be stored. This parameter cannot be NULL.

cbData [in]

This parameter is ignored. The function calculates this value based on the size of the data in the lpData parameter.

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

Remarks

If the key specified by the lpSubKey parameter does not exist, the RegSetValue function creates it.

If the ANSI version of this function is used (either by explicitly calling RegSetValueA or by not defining UNICODE before including the Windows.h file), the lpData parameter must be an ANSI character string. The string is converted to Unicode before it is stored in the registry.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winreg.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names

RegSetValueW (Unicode) and RegSetValueA (ANSI)

See also

RegCreateKeyEx
RegFlushKey
Registry Functions
Registry Overview
RegOpenKeyEx
RegQueryValueEx
RegSetValueEx

 

 

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft