[PATCH] advapi32: add RegSetKeyValue{A,W}

danielfsantos at att.net danielfsantos at att.net
Sat Jan 12 23:27:29 CST 2013


Adds RegSetKeyValue{A,W} to advapi32.dll
Refactors RegSetValue{A,W} to call RegSetKeyValue{A,W}
Fixes bug #32711
---
 dlls/advapi32/advapi32.spec |    4 +-
 dlls/advapi32/registry.c    |   81 +++++++++++++++++++++++++++++++++----------
 2 files changed, 64 insertions(+), 21 deletions(-)

diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec
index 21357fa..336518b 100644
--- a/dlls/advapi32/advapi32.spec
+++ b/dlls/advapi32/advapi32.spec
@@ -645,8 +645,8 @@
 # @ stub RegSaveKeyExW
 @ stdcall RegSaveKeyW(long ptr ptr)
 @ stdcall RegSetKeySecurity(long long ptr)
-# @ stub RegSetKeyValueA
-# @ stub RegSetKeyValueW
+@ stdcall RegSetKeyValueA(long str str long ptr long)
+@ stdcall RegSetKeyValueW(long str str long ptr long)
 @ stdcall RegSetValueA(long str long ptr long)
 @ stdcall RegSetValueExA(long str long long ptr long)
 @ stdcall RegSetValueExW(long wstr long long ptr long)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 744908f..ac1c8ca 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -1251,36 +1251,41 @@ LSTATUS WINAPI RegSetValueExA( HKEY hkey, LPCSTR name, DWORD reserved, DWORD typ
 
 
 /******************************************************************************
- * RegSetValueW   [ADVAPI32.@]
+ * RegSetKeyValueW   [ADVAPI32.@]
  *
- * Sets the data for the default or unnamed value of a reg key.
+ * Sets the data for the specified value in the specified registry key and subkey.
  *
  * PARAMS
- *  hKey     [I] Handle to an open key.
- *  lpSubKey [I] Name of a subkey of hKey.
- *  dwType   [I] Type of information to store.
- *  lpData   [I] String that contains the data to set for the default value.
- *  cbData   [I] Ignored.
+ *  hKey        [I] Handle to an open key.
+ *  lpSubKey    [I] Name of a subkey of hKey.
+ *  lpValueName [I] Name of the value to set or NULL for the default value.
+ *  dwType      [I] Type of information to store (ignored, always REG_SZ).
+ *  lpData      [I] String that contains the data to set for the value.
+ *  cbData      [I] Length of lpData (also ignored).
  *
  * RETURNS
  *  Success: ERROR_SUCCESS
  *  Failure: nonzero error code from Winerror.h
  */
-LSTATUS WINAPI RegSetValueW( HKEY hkey, LPCWSTR name, DWORD type, LPCWSTR data, DWORD count )
+LSTATUS WINAPI RegSetKeyValueW( HKEY hkey, LPCWSTR subkey_name,
+                                LPCWSTR value_name, DWORD type, LPCVOID data,
+								DWORD count )
 {
     HKEY subkey = hkey;
     DWORD ret;
 
-    TRACE("(%p,%s,%d,%s,%d)\n", hkey, debugstr_w(name), type, debugstr_w(data), count );
+    TRACE("(%p,%s,%s,%d,%s,%d)\n", hkey, debugstr_w(subkey_name),
+          debugstr_w(value_name), type, debugstr_w(data), count );
 
     if (type != REG_SZ || !data) return ERROR_INVALID_PARAMETER;
 
-    if (name && name[0])  /* need to create the subkey */
+    if (subkey_name && subkey_name[0])  /* need to create the subkey */
     {
-        if ((ret = RegCreateKeyW( hkey, name, &subkey )) != ERROR_SUCCESS) return ret;
+        ret = RegCreateKeyW( hkey, subkey_name, &subkey );
+        if (ret != ERROR_SUCCESS) return ret;
     }
 
-    ret = RegSetValueExW( subkey, NULL, 0, REG_SZ, (const BYTE*)data,
+    ret = RegSetValueExW( subkey, value_name, 0, REG_SZ, (const BYTE*)data,
                           (strlenW( data ) + 1) * sizeof(WCHAR) );
     if (subkey != hkey) RegCloseKey( subkey );
     return ret;
@@ -1288,29 +1293,67 @@ LSTATUS WINAPI RegSetValueW( HKEY hkey, LPCWSTR name, DWORD type, LPCWSTR data,
 
 
 /******************************************************************************
- * RegSetValueA   [ADVAPI32.@]
+ * RegSetKeyValueA   [ADVAPI32.@]
  *
- * See RegSetValueW.
+ * See RegSetKeyValueW
  */
-LSTATUS WINAPI RegSetValueA( HKEY hkey, LPCSTR name, DWORD type, LPCSTR data, DWORD count )
+LSTATUS WINAPI RegSetKeyValueA( HKEY hkey, LPCSTR subkey_name,
+                                LPCSTR value_name, DWORD type, LPCVOID data,
+								DWORD count )
 {
     HKEY subkey = hkey;
     DWORD ret;
 
-    TRACE("(%p,%s,%d,%s,%d)\n", hkey, debugstr_a(name), type, debugstr_a(data), count );
+    TRACE("(%p,%s,%s,%d,%s,%d)\n", hkey, debugstr_a(subkey_name),
+          debugstr_a(value_name), type, debugstr_a(data), count );
 
     if (type != REG_SZ || !data) return ERROR_INVALID_PARAMETER;
 
-    if (name && name[0])  /* need to create the subkey */
+    if (subkey_name && subkey_name[0])  /* need to create the subkey */
     {
-        if ((ret = RegCreateKeyA( hkey, name, &subkey )) != ERROR_SUCCESS) return ret;
+        ret = RegCreateKeyA( hkey, subkey_name, &subkey );
+        if (ret != ERROR_SUCCESS) return ret;
     }
-    ret = RegSetValueExA( subkey, NULL, 0, REG_SZ, (const BYTE*)data, strlen(data)+1 );
+
+    ret = RegSetValueExA( subkey, value_name, 0, REG_SZ, (const BYTE*)data,
+                          strlen(data) + 1 );
     if (subkey != hkey) RegCloseKey( subkey );
     return ret;
 }
 
 
+/******************************************************************************
+ * RegSetValueW   [ADVAPI32.@]
+ *
+ * Sets the data for the default or unnamed value of a reg key.
+ *
+ * PARAMS
+ *  hKey     [I] Handle to an open key.
+ *  lpSubKey [I] Name of a subkey of hKey.
+ *  dwType   [I] Type of information to store (ignored, always REG_SZ).
+ *  lpData   [I] String that contains the data to set for the default value.
+ *  cbData   [I] Ignored.
+ *
+ * RETURNS
+ *  Success: ERROR_SUCCESS
+ *  Failure: nonzero error code from Winerror.h
+ */
+LSTATUS WINAPI RegSetValueW( HKEY hkey, LPCWSTR name, DWORD type, LPCWSTR data, DWORD count )
+{
+	return RegSetKeyValueW(hkey, name, NULL, type, data, count);
+}
+
+
+/******************************************************************************
+ * RegSetValueA   [ADVAPI32.@]
+ *
+ * See RegSetValueW.
+ */
+LSTATUS WINAPI RegSetValueA( HKEY hkey, LPCSTR name, DWORD type, LPCSTR data, DWORD count )
+{
+	return RegSetKeyValueA(hkey, name, NULL, type, data, count);
+}
+
 
 /******************************************************************************
  * RegQueryValueExW   [ADVAPI32.@]
-- 
1.7.8.6




More information about the wine-patches mailing list