From 3e3ed6f431c034cfac77c8f0856e2f2ac7846017 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 5 Dec 2018 08:58:18 +0300 Subject: [PATCH] shlwapi: Forward SHCopyKey() to shcore. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/shlwapi/reg.c | 133 ---------------------------------------------- dlls/shlwapi/shlwapi.spec | 4 +- 2 files changed, 2 insertions(+), 135 deletions(-) diff --git a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c index fa091abd859..2ff797793f0 100644 --- a/dlls/shlwapi/reg.c +++ b/dlls/shlwapi/reg.c @@ -1994,139 +1994,6 @@ HKEY WINAPI SHRegDuplicateHKey(HKEY hKey) return newKey; } - -/************************************************************************* - * SHCopyKeyA [SHLWAPI.@] - * - * Copy a key and its values/sub keys to another location. - * - * PARAMS - * hKeySrc [I] Source key to copy from - * lpszSrcSubKey [I] Sub key under hKeySrc, or NULL to use hKeySrc directly - * hKeyDst [I] Destination key - * dwReserved [I] Reserved, must be 0 - * - * RETURNS - * Success: ERROR_SUCCESS. The key is copied to the destination key. - * Failure: A standard windows error code. - * - * NOTES - * If hKeyDst is a key under hKeySrc, this function will misbehave - * (It will loop until out of stack, or the registry is full). This - * bug is present in Win32 also. - */ -DWORD WINAPI SHCopyKeyA(HKEY hKeySrc, LPCSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved) -{ - WCHAR szSubKeyW[MAX_PATH]; - - TRACE("(hkey=%p,%s,%p08x,%d)\n", hKeySrc, debugstr_a(lpszSrcSubKey), hKeyDst, dwReserved); - - if (lpszSrcSubKey) - MultiByteToWideChar(CP_ACP, 0, lpszSrcSubKey, -1, szSubKeyW, MAX_PATH); - - return SHCopyKeyW(hKeySrc, lpszSrcSubKey ? szSubKeyW : NULL, hKeyDst, dwReserved); -} - -/************************************************************************* - * SHCopyKeyW [SHLWAPI.@] - * - * See SHCopyKeyA. - */ -DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved) -{ - DWORD dwKeyCount = 0, dwValueCount = 0, dwMaxKeyLen = 0; - DWORD dwMaxValueLen = 0, dwMaxDataLen = 0, i; - BYTE buff[1024]; - LPVOID lpBuff = buff; - WCHAR szName[MAX_PATH], *lpszName = szName; - DWORD dwRet = S_OK; - - TRACE("hkey=%p,%s,%p08x,%d)\n", hKeySrc, debugstr_w(lpszSrcSubKey), hKeyDst, dwReserved); - - if(!hKeyDst || !hKeySrc) - dwRet = ERROR_INVALID_PARAMETER; - else - { - /* Open source key */ - if(lpszSrcSubKey) - dwRet = RegOpenKeyExW(hKeySrc, lpszSrcSubKey, 0, KEY_ALL_ACCESS, &hKeySrc); - - if(dwRet) - hKeyDst = NULL; /* Don't close this key since we didn't open it */ - else - { - /* Get details about sub keys and values */ - dwRet = RegQueryInfoKeyW(hKeySrc, NULL, NULL, NULL, &dwKeyCount, &dwMaxKeyLen, - NULL, &dwValueCount, &dwMaxValueLen, &dwMaxDataLen, - NULL, NULL); - if(!dwRet) - { - if (dwMaxValueLen > dwMaxKeyLen) - dwMaxKeyLen = dwMaxValueLen; /* Get max size for key/value names */ - - if (dwMaxKeyLen++ > MAX_PATH - 1) - lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxKeyLen * sizeof(WCHAR)); - - if (dwMaxDataLen > sizeof(buff)) - lpBuff = HeapAlloc(GetProcessHeap(), 0, dwMaxDataLen); - - if (!lpszName || !lpBuff) - dwRet = ERROR_NOT_ENOUGH_MEMORY; - } - } - } - - /* Copy all the sub keys */ - for(i = 0; i < dwKeyCount && !dwRet; i++) - { - HKEY hSubKeySrc, hSubKeyDst; - DWORD dwSize = dwMaxKeyLen; - - dwRet = RegEnumKeyExW(hKeySrc, i, lpszName, &dwSize, NULL, NULL, NULL, NULL); - - if(!dwRet) - { - /* Open source sub key */ - dwRet = RegOpenKeyExW(hKeySrc, lpszName, 0, KEY_READ, &hSubKeySrc); - - if(!dwRet) - { - /* Create destination sub key */ - dwRet = RegCreateKeyW(hKeyDst, lpszName, &hSubKeyDst); - - if(!dwRet) - { - /* Recursively copy keys and values from the sub key */ - dwRet = SHCopyKeyW(hSubKeySrc, NULL, hSubKeyDst, 0); - RegCloseKey(hSubKeyDst); - } - } - RegCloseKey(hSubKeySrc); - } - } - - /* Copy all the values in this key */ - for (i = 0; i < dwValueCount && !dwRet; i++) - { - DWORD dwNameSize = dwMaxKeyLen, dwType, dwLen = dwMaxDataLen; - - dwRet = RegEnumValueW(hKeySrc, i, lpszName, &dwNameSize, NULL, &dwType, lpBuff, &dwLen); - - if (!dwRet) - dwRet = SHSetValueW(hKeyDst, NULL, lpszName, dwType, lpBuff, dwLen); - } - - /* Free buffers if allocated */ - if (lpszName != szName) - HeapFree(GetProcessHeap(), 0, lpszName); - if (lpBuff != buff) - HeapFree(GetProcessHeap(), 0, lpBuff); - - if (lpszSrcSubKey && hKeyDst) - RegCloseKey(hKeyDst); - return dwRet; -} - /* * The following functions are ORDINAL ONLY: */ diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec index c104d82923f..55655a627c4 100644 --- a/dlls/shlwapi/shlwapi.spec +++ b/dlls/shlwapi/shlwapi.spec @@ -680,8 +680,8 @@ @ stdcall PathUnquoteSpacesA (str) @ stdcall PathUnquoteSpacesW (wstr) @ stdcall SHAutoComplete(ptr long) -@ stdcall SHCopyKeyA(long str long long) -@ stdcall SHCopyKeyW(long wstr long long) +@ stdcall SHCopyKeyA(long str long long) shcore.SHCopyKeyA +@ stdcall SHCopyKeyW(long wstr long long) shcore.SHCopyKeyW @ stdcall SHCreateShellPalette(long) @ stdcall SHCreateStreamOnFileA(str long ptr) shcore.SHCreateStreamOnFileA @ stdcall SHCreateStreamOnFileEx(wstr long long long ptr ptr) shcore.SHCreateStreamOnFileEx -- 2.11.4.GIT