From a88f66d1556a9b721f818af7d5e0fdcc6a08f54d Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 29 Nov 2018 12:06:13 +0300 Subject: [PATCH] shcore: Add SHRegDuplicateHKey(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/shcore/main.c | 12 ++++++++++++ dlls/shcore/shcore.spec | 2 +- dlls/shcore/tests/Makefile.in | 1 + dlls/shcore/tests/shcore.c | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/dlls/shcore/main.c b/dlls/shcore/main.c index 1228c9d0e16..96ba7d791b4 100644 --- a/dlls/shcore/main.c +++ b/dlls/shcore/main.c @@ -1751,3 +1751,15 @@ DWORD WINAPI SHAnsiToUnicode(const char *src, WCHAR *dest, int dest_len) return ret; } + +/************************************************************************* + * SHRegDuplicateHKey [SHCORE.@] + */ +HKEY WINAPI SHRegDuplicateHKey(HKEY hKey) +{ + HKEY newKey = 0; + + RegOpenKeyExW(hKey, 0, 0, MAXIMUM_ALLOWED, &newKey); + TRACE("new key is %p\n", newKey); + return newKey; +} diff --git a/dlls/shcore/shcore.spec b/dlls/shcore/shcore.spec index bd2bf12df1a..c7a8744a2ca 100644 --- a/dlls/shcore/shcore.spec +++ b/dlls/shcore/shcore.spec @@ -61,7 +61,7 @@ @ stdcall SHQueryInfoKeyW(long ptr ptr ptr ptr) shlwapi.SHQueryInfoKeyW @ stdcall SHQueryValueExA(long str ptr ptr ptr ptr) shlwapi.SHQueryValueExA @ stdcall SHQueryValueExW(long wstr ptr ptr ptr ptr) shlwapi.SHQueryValueExW -@ stdcall SHRegDuplicateHKey(long) shlwapi.SHRegDuplicateHKey +@ stdcall SHRegDuplicateHKey(long) @ stdcall SHRegGetIntW(ptr wstr long) shlwapi.SHRegGetIntW @ stdcall SHRegGetPathA(long str str ptr long) shlwapi.SHRegGetPathA @ stdcall SHRegGetPathW(long wstr wstr ptr long) shlwapi.SHRegGetPathW diff --git a/dlls/shcore/tests/Makefile.in b/dlls/shcore/tests/Makefile.in index 0ea769a348d..4f537fa3874 100644 --- a/dlls/shcore/tests/Makefile.in +++ b/dlls/shcore/tests/Makefile.in @@ -1,4 +1,5 @@ TESTDLL = shcore.dll +IMPORTS = advapi32 C_SRCS = \ shcore.c diff --git a/dlls/shcore/tests/shcore.c b/dlls/shcore/tests/shcore.c index f788afdd22b..0945e121748 100644 --- a/dlls/shcore/tests/shcore.c +++ b/dlls/shcore/tests/shcore.c @@ -33,6 +33,7 @@ static int (WINAPI *pSHUnicodeToAnsi)(const WCHAR *, char *, int); static int (WINAPI *pSHAnsiToUnicode)(const char *, WCHAR *, int); static int (WINAPI *pSHAnsiToAnsi)(const char *, char *, int); static int (WINAPI *pSHUnicodeToUnicode)(const WCHAR *, WCHAR *, int); +static HKEY (WINAPI *pSHRegDuplicateHKey)(HKEY); static void init(HMODULE hshcore) { @@ -43,6 +44,7 @@ static void init(HMODULE hshcore) X(SHAnsiToUnicode); X(SHAnsiToAnsi); X(SHUnicodeToUnicode); + X(SHRegDuplicateHKey); #undef X } @@ -300,6 +302,23 @@ static void test_SHUnicodeToUnicode(void) ok(buff[5] == 'f', "Unexpected buffer contents.\n"); } +static void test_SHRegDuplicateHKey(void) +{ + HKEY hkey, hkey2; + DWORD ret; + + ret = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkey); + ok(!ret, "Failed to create test key, ret %d.\n", ret); + + hkey2 = pSHRegDuplicateHKey(hkey); + ok(hkey2 != NULL && hkey2 != hkey, "Unexpected duplicate key.\n"); + + RegCloseKey(hkey2); + RegCloseKey(hkey); + + RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test"); +} + START_TEST(shcore) { HMODULE hshcore = LoadLibraryA("shcore.dll"); @@ -317,4 +336,5 @@ START_TEST(shcore) test_SHAnsiToUnicode(); test_SHAnsiToAnsi(); test_SHUnicodeToUnicode(); + test_SHRegDuplicateHKey(); }