Registry::SetValue

Contents

Description

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


Sets the data for a specified value name associated with a subkey.


Sets the data for the default or unnamed value of a specified registry key.

Syntax

void SetValue( LPCSTR lpSubKey, LPCSTR lpValueName, LPCSTR lpValue )

void SetValue( LPCSTR lpSubKey, LPCSTR lpValueName, DWORD dwValue )

void SetValue( LPCSTR lpSubKey, LPCSTR lpValueName, LPBYTE lpData, DWORD dwType, DWORD dwcbData )

Parameters

lpSubKey
Pointer to a null-terminated string containing the name of the subkey.
If the lpSubKey does not exist, it will be created there
lpValueName
Pointer to a string containing the name of the value,
If lpszValueName is supplied, the name value pair lpszValueName = lpszValue will be created for the key.
If lpszValueName is NULL, the default value of the lpSubKey will be set to lpszValue.
lpValue
Pointer to a null-terminated string containing the data to set for the default value of the specified key.

lpSubKey
Pointer to a null-terminated string containing the name of the subkey to open.
lpValueName
Pointer to a string containing the name of the value to set.
dwValue
a unsigned int value

lpSubKey
Pointer to a null-terminated string containing the name of the subkey.
If the lpSubKey does not exist, it will be created there
lpValueName
Pointer to a string containing the name of the value,
If lpszValueName is NULL, the default value of the lpSubKey will be set to lpszValue.
lpData
Pointer to a buffer containing the data to be stored with the specified value name.
dwType
Specifies a code indicating the type of data pointed to by the lpData parameter.
dwcbData
Specifies the size of the information pointed to by the lpData parameter, in bytes.

Return

Examples

EX1

void Registry_SetValue_ex1()
{
    string strLabel = "Test";
    Registry myRegAccess(HKEY_CLASSES_ROOT);
    if( myRegAccess.HasKey("a\\b\\c") )
        myRegAccess.SetValue("a\\b\\c", "Label", strLabel);
}


EX2

void Registry_SetValue_ex2()
{
    Registry myRegAccess(HKEY_CLASSES_ROOT);
    if( myRegAccess.HasKey("a\\b\\c") )
        myRegAccess.SetValue("a\\b\\c", "Control", 12345);
}


EX3

void Registry_SetValue_ex3()
{
    Registry myRegAccess(HKEY_CURRENT_USER);
       vector<byte> vb = {43, 44, 45, 46, 47, 48, 49, 0};
       DWORD dwType = REG_BINARY;
       DWORD dwNumBytes = 8;
   
       if( myRegAccess.HasKey("a\\b\\c") )
          myRegAccess.SetValue("a\\b\\c", "Place1", vb, dwType, dwNumBytes);
}

Remark

See Also

header to Include

origin.h