Commit 50a18ca5 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

shlwapi: Unify SHDeleteKeyW implementation with SHDeleteKeyA.

parent 75dd3534
...@@ -503,9 +503,7 @@ static BOOL do_typelib_reg_key(GUID *uid, WORD maj, WORD min, LPCWSTR base, BOOL ...@@ -503,9 +503,7 @@ static BOOL do_typelib_reg_key(GUID *uid, WORD maj, WORD min, LPCWSTR base, BOOL
if (remove) if (remove)
{ {
todo_wine {
ok(SHDeleteKeyW(HKEY_CLASSES_ROOT, buf) == ERROR_SUCCESS, "SHDeleteKey failed\n"); ok(SHDeleteKeyW(HKEY_CLASSES_ROOT, buf) == ERROR_SUCCESS, "SHDeleteKey failed\n");
}
return TRUE; return TRUE;
} }
......
...@@ -1553,7 +1553,7 @@ DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey) ...@@ -1553,7 +1553,7 @@ DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
*/ */
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey) 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; WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
HKEY hSubKey = 0; HKEY hSubKey = 0;
...@@ -1562,8 +1562,8 @@ DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey) ...@@ -1562,8 +1562,8 @@ DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
dwRet = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey); dwRet = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
if(!dwRet) if(!dwRet)
{ {
/* Find how many subkeys there are */ /* Find the maximum subkey length so that we can allocate a buffer */
dwRet = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &dwKeyCount, dwRet = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
&dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL); &dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
if(!dwRet) if(!dwRet)
{ {
...@@ -1576,15 +1576,16 @@ DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey) ...@@ -1576,15 +1576,16 @@ DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
dwRet = ERROR_NOT_ENOUGH_MEMORY; dwRet = ERROR_NOT_ENOUGH_MEMORY;
else else
{ {
/* Recursively delete all the subkeys */ while (dwRet == ERROR_SUCCESS)
for(i = 0; i < dwKeyCount && !dwRet; i++)
{ {
dwSize = dwMaxSubkeyLen; dwSize = dwMaxSubkeyLen;
dwRet = RegEnumKeyExW(hSubKey, i, lpszName, &dwSize, NULL, NULL, NULL, NULL); dwRet = RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL, NULL, NULL, NULL);
if(!dwRet) if (dwRet == ERROR_SUCCESS || dwRet == ERROR_MORE_DATA)
dwRet = SHDeleteKeyW(hSubKey, lpszName); dwRet = SHDeleteKeyW(hSubKey, lpszName);
} }
if (dwRet == ERROR_NO_MORE_ITEMS)
dwRet = ERROR_SUCCESS;
if (lpszName != szNameBuf) if (lpszName != szNameBuf)
HeapFree(GetProcessHeap(), 0, lpszName); /* Free buffer if allocated */ HeapFree(GetProcessHeap(), 0, lpszName); /* Free buffer if allocated */
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment