[PATCH 2/5] shlwapi: Forward SHDeleteKey() to shcore.

Nikolay Sivov nsivov at codeweavers.com
Mon Dec 3 23:02:49 CST 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/shlwapi/reg.c        | 77 ---------------------------------------
 dlls/shlwapi/shlwapi.spec |  4 +-
 2 files changed, 2 insertions(+), 79 deletions(-)

diff --git a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c
index 370161df12..5faad4a2d6 100644
--- a/dlls/shlwapi/reg.c
+++ b/dlls/shlwapi/reg.c
@@ -1513,83 +1513,6 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue,
   return dwRet;
 }
 
-/*************************************************************************
- * SHDeleteKeyA   [SHLWAPI.@]
- *
- * Delete a registry key and any sub keys/values present
- *
- * This function forwards to the unicode version directly, to avoid
- * handling subkeys that are not representable in ASCII.
- *
- * PARAMS
- *   hKey       [I] Handle to registry key
- *   lpszSubKey [I] Name of sub key to delete
- *
- * RETURNS
- *   Success: ERROR_SUCCESS. The key is deleted.
- *   Failure: An error code from RegOpenKeyExA(), RegQueryInfoKeyA(),
- *            RegEnumKeyExA() or RegDeleteKeyA().
- */
-DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
-{
-  WCHAR subkeyW[MAX_PATH];
-
-  MultiByteToWideChar (CP_ACP, 0, lpszSubKey, -1, subkeyW, ARRAY_SIZE(subkeyW));
-  return SHDeleteKeyW(hKey, subkeyW);
-}
-
-/*************************************************************************
- * SHDeleteKeyW   [SHLWAPI.@]
- *
- * See SHDeleteKeyA.
- */
-DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
-{
-  DWORD dwRet, dwMaxSubkeyLen = 0, dwSize;
-  WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
-  HKEY hSubKey = 0;
-
-  TRACE("(hkey=%p,%s)\n", hKey, debugstr_w(lpszSubKey));
-
-  dwRet = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
-  if(!dwRet)
-  {
-    /* Find the maximum subkey length so that we can allocate a buffer */
-    dwRet = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
-                             &dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
-    if(!dwRet)
-    {
-      dwMaxSubkeyLen++;
-      if (dwMaxSubkeyLen > ARRAY_SIZE(szNameBuf))
-        /* Name too big: alloc a buffer for it */
-        lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(WCHAR));
-
-      if(!lpszName)
-        dwRet = ERROR_NOT_ENOUGH_MEMORY;
-      else
-      {
-        while (dwRet == ERROR_SUCCESS)
-        {
-          dwSize = dwMaxSubkeyLen;
-          dwRet = RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL, NULL, NULL, NULL);
-          if (dwRet == ERROR_SUCCESS || dwRet == ERROR_MORE_DATA)
-            dwRet = SHDeleteKeyW(hSubKey, lpszName);
-        }
-        if (dwRet == ERROR_NO_MORE_ITEMS)
-          dwRet = ERROR_SUCCESS;
-    
-        if (lpszName != szNameBuf)
-          HeapFree(GetProcessHeap(), 0, lpszName); /* Free buffer if allocated */
-      }
-    }
-
-    RegCloseKey(hSubKey);
-    if(!dwRet)
-      dwRet = RegDeleteKeyW(hKey, lpszSubKey);
-  }
-  return dwRet;
-}
-
 /*************************************************************************
  * SHDeleteOrphanKeyA   [SHLWAPI.@]
  *
diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec
index a51088dba8..f8ffd36725 100644
--- a/dlls/shlwapi/shlwapi.spec
+++ b/dlls/shlwapi/shlwapi.spec
@@ -690,8 +690,8 @@
 @ stdcall SHCreateThreadRef(ptr ptr) shcore.SHCreateThreadRef
 @ stdcall SHDeleteEmptyKeyA(long str) shcore.SHDeleteEmptyKeyA
 @ stdcall SHDeleteEmptyKeyW(long wstr) shcore.SHDeleteEmptyKeyW
-@ stdcall SHDeleteKeyA(long str)
-@ stdcall SHDeleteKeyW(long wstr)
+@ stdcall SHDeleteKeyA(long str) shcore.SHDeleteKeyA
+@ stdcall SHDeleteKeyW(long wstr) shcore.SHDeleteKeyW
 @ stdcall SHDeleteOrphanKeyA(long str)
 @ stdcall SHDeleteOrphanKeyW(long wstr)
 @ stdcall SHDeleteValueA(long  str  str)
-- 
2.19.2




More information about the wine-devel mailing list