[PATCH] forward SHDeleteKeyA directly to SHDeleteKeyW
Marcus Meissner
marcus at jet.franken.de
Sun Dec 3 09:09:24 CST 2006
Hi,
Sometimes subkeys might be non-ascii representable
and a true ascii recursion would break down here.
I experienced this in comctl32/tests/mru when
a non-ascii key was left in the registry tree
below Software\Wine\Test
Ciao, Marcus
---
dlls/shlwapi/reg.c | 47 ++++++-----------------------------------------
1 files changed, 6 insertions(+), 41 deletions(-)
b6e8c7073de2ea7e25ee73bf955e48a3f9e9368f
diff --git a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c
index 8d4e4c1..e1182ff 100644
--- a/dlls/shlwapi/reg.c
+++ b/dlls/shlwapi/reg.c
@@ -1491,6 +1491,9 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey,
*
* 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
@@ -1502,48 +1505,10 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey,
*/
DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
{
- DWORD dwRet, dwMaxSubkeyLen = 0, dwSize;
- CHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
- HKEY hSubKey = 0;
-
- TRACE("(hkey=%p,%s)\n", hKey, debugstr_a(lpszSubKey));
-
- dwRet = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
- if(!dwRet)
- {
- /* Find the maximum subkey length so that we can allocate a buffer */
- dwRet = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, NULL,
- &dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
- if(!dwRet)
- {
- dwMaxSubkeyLen++;
- if (dwMaxSubkeyLen > sizeof(szNameBuf))
- /* Name too big: alloc a buffer for it */
- lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(CHAR));
-
- if(!lpszName)
- dwRet = ERROR_NOT_ENOUGH_MEMORY;
- else
- {
- while (dwRet == ERROR_SUCCESS)
- {
- dwSize = dwMaxSubkeyLen;
- dwRet = RegEnumKeyExA(hSubKey, 0, lpszName, &dwSize, NULL, NULL, NULL, NULL);
- if (dwRet == ERROR_SUCCESS || dwRet == ERROR_MORE_DATA)
- dwRet = SHDeleteKeyA(hSubKey, lpszName);
- }
- if (dwRet == ERROR_NO_MORE_ITEMS)
- dwRet = ERROR_SUCCESS;
- if (lpszName != szNameBuf)
- HeapFree(GetProcessHeap(), 0, lpszName); /* Free buffer if allocated */
- }
- }
+ WCHAR subkeyW[MAX_PATH];
- RegCloseKey(hSubKey);
- if(!dwRet)
- dwRet = RegDeleteKeyA(hKey, lpszSubKey);
- }
- return dwRet;
+ MultiByteToWideChar (CP_ACP, 0, lpszSubKey, -1, subkeyW, sizeof(subkeyW)/sizeof(WCHAR));
+ return SHDeleteKeyW(hKey, subkeyW);
}
/*************************************************************************
--
1.2.4
More information about the wine-patches
mailing list