[v2 PATCH 3/4] shcore: Add SHRegDuplicateHKey().

Nikolay Sivov nsivov at codeweavers.com
Wed Nov 28 23:57:10 CST 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 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 2c592c858c..906eb78c72 100644
--- a/dlls/shcore/main.c
+++ b/dlls/shcore/main.c
@@ -1763,3 +1763,15 @@ DWORD WINAPI SHAnsiToUnicode(const char *src, WCHAR *dest, int dest_len)
     dest[dest_len - 1] = 0;
     return dest_len;
 }
+
+/*************************************************************************
+ * 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 bd2bf12df1..c7a8744a2c 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 0ea769a348..4f537fa387 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 15fcda5449..7412297804 100644
--- a/dlls/shcore/tests/shcore.c
+++ b/dlls/shcore/tests/shcore.c
@@ -31,6 +31,7 @@ static void (WINAPI *pSetProcessReference)(IUnknown *);
 static HRESULT (WINAPI *pSHGetInstanceExplorer)(IUnknown **);
 static int (WINAPI *pSHUnicodeToAnsi)(const WCHAR *, char *, int);
 static int (WINAPI *pSHAnsiToUnicode)(const char *, WCHAR *, int);
+static HKEY (WINAPI *pSHRegDuplicateHKey)(HKEY);
 
 static void init(HMODULE hshcore)
 {
@@ -39,6 +40,7 @@ static void init(HMODULE hshcore)
     X(SetProcessReference);
     X(SHUnicodeToAnsi);
     X(SHAnsiToUnicode);
+    X(SHRegDuplicateHKey);
 #undef X
 }
 
@@ -215,6 +217,23 @@ static void test_SHAnsiToUnicode(void)
     ok(buffW[0] == 't' && buffW[1] == 0, "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");
@@ -230,4 +249,5 @@ START_TEST(shcore)
     test_process_reference();
     test_SHUnicodeToAnsi();
     test_SHAnsiToUnicode();
+    test_SHRegDuplicateHKey();
 }
-- 
2.19.2




More information about the wine-devel mailing list