From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/advapi32/registry.c | 22 +++++++++++++++++++--- dlls/advapi32/tests/registry.c | 14 -------------- 2 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index 730ca850c2b..85e883bdcc9 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -510,10 +510,26 @@ LSTATUS WINAPI RegReplaceKeyW( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewFile, * RegRenameKey [ADVAPI32.@] * */ -LSTATUS WINAPI RegRenameKey( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewName ) +LSTATUS WINAPI RegRenameKey( HKEY hkey, LPCWSTR subkey_name, LPCWSTR new_name ) { - FIXME("(%p,%s,%s): stub\n", hkey, debugstr_w(lpSubKey), debugstr_w(lpNewName)); - return ERROR_CALL_NOT_IMPLEMENTED; + UNICODE_STRING str; + LSTATUS ret; + HKEY subkey; + + TRACE("%p, %s, %s.\n", hkey, debugstr_w(subkey_name), debugstr_w(new_name)); + + RtlInitUnicodeString(&str, new_name); + + if (!subkey_name) + return RtlNtStatusToDosError( NtRenameKey( hkey, &str )); + + if ((ret = RegOpenKeyExW( hkey, subkey_name, 0, KEY_WRITE, &subkey ))) + return ret; + + ret = RtlNtStatusToDosError( NtRenameKey( subkey, &str )); + RegCloseKey( subkey ); + + return ret; }
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index c2e78192f2e..cae9fc98734 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -4481,22 +4481,17 @@ static void test_RegRenameKey(void) LSTATUS ret;
ret = RegRenameKey(NULL, NULL, NULL); - todo_wine ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %ld.\n", ret); ret = RegRenameKey(NULL, NULL, L"newname"); - todo_wine ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret); ret = RegRenameKey(NULL, L"oldname", NULL); - todo_wine ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret); ret = RegRenameKey(NULL, L"oldname", L"newname"); - todo_wine ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret);
ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_READ, NULL, &key, NULL); ok(!ret, "Unexpected return value %ld.\n", ret); ret = RegRenameKey(key, NULL, L"TestNewRenameKey"); - todo_wine ok(ret == ERROR_ACCESS_DENIED, "Unexpected return value %ld.\n", ret); RegCloseKey(key);
@@ -4504,28 +4499,22 @@ static void test_RegRenameKey(void) ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL); ok(!ret, "Unexpected return value %ld.\n", ret); ret = RegRenameKey(key, NULL, NULL); - todo_wine ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %ld.\n", ret); ret = RegRenameKey(key, NULL, L"TestNewRenameKey"); - todo_wine ok(!ret, "Unexpected return value %ld.\n", ret); RegCloseKey(key);
ret = RegDeleteKeyA(hkey_main, "TestNewRenameKey"); - todo_wine ok(!ret, "Unexpected return value %ld.\n", ret); ret = RegDeleteKeyA(hkey_main, "TestRenameKey"); - todo_wine ok(ret, "Unexpected return value %ld.\n", ret);
/* Subkey does not exist. */ ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL); ok(!ret, "Unexpected return value %ld.\n", ret); ret = RegRenameKey(key, L"unknown_subkey", NULL); - todo_wine ok(ret == ERROR_FILE_NOT_FOUND, "Unexpected return value %ld.\n", ret); ret = RegRenameKey(key, L"unknown_subkey", L"known_subkey"); - todo_wine ok(ret == ERROR_FILE_NOT_FOUND, "Unexpected return value %ld.\n", ret);
/* Rename existing subkey. */ @@ -4534,14 +4523,11 @@ static void test_RegRenameKey(void) RegCloseKey(key2);
ret = RegRenameKey(key, L"known_subkey", L"renamed_subkey"); - todo_wine ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegDeleteKeyA(key, "renamed_subkey"); - todo_wine ok(!ret, "Unexpected return value %ld.\n", ret); ret = RegDeleteKeyA(key, "known_subkey"); - todo_wine ok(ret, "Unexpected return value %ld.\n", ret);
RegCloseKey(key);