shlwapi: Forward SHDeleteKey() to shcore.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
a587b7938b
commit
5f42d67dc5
|
@ -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.@]
|
||||
*
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue