Writes a value to a registry subkey in a user-specific subtree (HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE).
LSTATUS SHRegWriteUSValueA( HUSKEY hUSKey, LPCSTR pszValue, DWORD dwType, const void *pvData, DWORD cbData, DWORD dwFlags );
A handle to a currently open registry subkey. The subkey must have been opened with the KEY_SET_VALUE access right. For more information, see Registry Key Security and Access Rights.
This handle can be obtained through the SHRegOpenUSKey function.
A pointer to a null-terminated string that specifies the name of the value. This value is an entry in the subkey specified by hUSKey. If a value with this name is not already present in the subkey, it will be added.
If this parameter is NULL or an empty string, the function sets the type and data for the subkey's Default value.
The type of the data to be stored in the value specified by pszValue. One of the following registry value types defined in Winnt.h and Wdm.h.
Type: const void*
A pointer to the data to be set for the value specified by pszValue. 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. A backslash in a path must be preceded by another backslash as an escape character. For example, specify "C:\mydir\myfile" to store the string "C:\mydir\myfile".
The size, in bytes, of the data pointed to by the pvData parameter. 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.
Flags that indicate the subtree to which the data should be written. One or more of the following values:
Write to HKEY_CURRENT_USER only if a value of the name specified in pszValue does not currently exist under the specified subkey.
Write to HKEY_CURRENT_USER. If a value of the name specified in pszValue already exists, it will be overwritten.
Write to HKEY_LOCAL_MACHINE only if a value of the name specified in pszValue does not currently exist under the specified subkey..
Write to HKEY_LOCAL_MACHINE. If a value of the name specified in pszValue already exists, it will be overwritten.
Equivalent to (SHREGSET_FORCE_HKCU | SHREGSET_HKLM).
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.
To use SHRegWriteUSValue, you must first open the key with SHRegOpenUSKey. Once the key is opened, you can use SHRegWriteUSValue as many times as necessary.
If you only need to write a single value, you should use SHRegSetUSValue, which both opens the key and writes the value.
If you need to write more than one value on the same key, multiple calls to SHRegWriteUSValue are usually more efficient than SHRegSetUSValue, because the key is only opened once.
|Minimum supported client||Windows 2000 Professional, Windows XP [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|DLL||Shlwapi.dll (version 4.71 or later)|