shlwapi: Unify SHDeleteKeyW implementation with SHDeleteKeyA
Dmitry Timoshkov
dmitry at codeweavers.com
Fri Nov 10 04:57:27 CST 2006
Hello,
looks like long time ago somebody has fixed SHDeleteKeyA but forgot
about its unicode counterpart.
Changelog:
shlwapi: Unify SHDeleteKeyW implementation with SHDeleteKeyA.
diff -up a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c
--- a/dlls/oleaut32/tests/typelib.c 2006-11-08 13:55:13.000000000 +0800
+++ b/dlls/oleaut32/tests/typelib.c 2006-11-10 17:27:43.000000000 +0800
@@ -503,9 +503,7 @@ static BOOL do_typelib_reg_key(GUID *uid
if (remove)
{
-todo_wine {
ok(SHDeleteKeyW(HKEY_CLASSES_ROOT, buf) == ERROR_SUCCESS, "SHDeleteKey failed\n");
-}
return TRUE;
}
diff -up a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c
--- a/dlls/shlwapi/reg.c 2006-10-16 12:27:17.000000000 +0900
+++ b/dlls/shlwapi/reg.c 2006-11-10 17:31:10.000000000 +0800
@@ -1553,7 +1553,7 @@ DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPC
*/
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
{
- DWORD dwRet, dwKeyCount = 0, dwMaxSubkeyLen = 0, dwSize, i;
+ DWORD dwRet, dwMaxSubkeyLen = 0, dwSize;
WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
HKEY hSubKey = 0;
@@ -1562,8 +1562,8 @@ DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPC
dwRet = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
if(!dwRet)
{
- /* Find how many subkeys there are */
- dwRet = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &dwKeyCount,
+ /* 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)
{
@@ -1576,15 +1576,16 @@ DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPC
dwRet = ERROR_NOT_ENOUGH_MEMORY;
else
{
- /* Recursively delete all the subkeys */
- for(i = 0; i < dwKeyCount && !dwRet; i++)
+ while (dwRet == ERROR_SUCCESS)
{
dwSize = dwMaxSubkeyLen;
- dwRet = RegEnumKeyExW(hSubKey, i, lpszName, &dwSize, NULL, NULL, NULL, NULL);
- if(!dwRet)
+ 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 */
}
More information about the wine-patches
mailing list