Commit ebbee24c authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

advapi32: Implement RegRenameKey().

parent 1fb6f271
...@@ -510,10 +510,26 @@ LSTATUS WINAPI RegReplaceKeyW( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewFile, ...@@ -510,10 +510,26 @@ LSTATUS WINAPI RegReplaceKeyW( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewFile,
* RegRenameKey [ADVAPI32.@] * 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)); UNICODE_STRING str;
return ERROR_CALL_NOT_IMPLEMENTED; 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;
} }
......
...@@ -4481,22 +4481,17 @@ static void test_RegRenameKey(void) ...@@ -4481,22 +4481,17 @@ static void test_RegRenameKey(void)
LSTATUS ret; LSTATUS ret;
ret = RegRenameKey(NULL, NULL, NULL); ret = RegRenameKey(NULL, NULL, NULL);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %ld.\n", ret); ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(NULL, NULL, L"newname"); ret = RegRenameKey(NULL, NULL, L"newname");
todo_wine
ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret); ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(NULL, L"oldname", NULL); ret = RegRenameKey(NULL, L"oldname", NULL);
todo_wine
ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret); ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(NULL, L"oldname", L"newname"); ret = RegRenameKey(NULL, L"oldname", L"newname");
todo_wine
ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret); ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret);
ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_READ, NULL, &key, NULL); ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_READ, NULL, &key, NULL);
ok(!ret, "Unexpected return value %ld.\n", ret); ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, NULL, L"TestNewRenameKey"); ret = RegRenameKey(key, NULL, L"TestNewRenameKey");
todo_wine
ok(ret == ERROR_ACCESS_DENIED, "Unexpected return value %ld.\n", ret); ok(ret == ERROR_ACCESS_DENIED, "Unexpected return value %ld.\n", ret);
RegCloseKey(key); RegCloseKey(key);
...@@ -4504,28 +4499,22 @@ static void test_RegRenameKey(void) ...@@ -4504,28 +4499,22 @@ static void test_RegRenameKey(void)
ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL); ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL);
ok(!ret, "Unexpected return value %ld.\n", ret); ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, NULL, NULL); ret = RegRenameKey(key, NULL, NULL);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %ld.\n", ret); ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, NULL, L"TestNewRenameKey"); ret = RegRenameKey(key, NULL, L"TestNewRenameKey");
todo_wine
ok(!ret, "Unexpected return value %ld.\n", ret); ok(!ret, "Unexpected return value %ld.\n", ret);
RegCloseKey(key); RegCloseKey(key);
ret = RegDeleteKeyA(hkey_main, "TestNewRenameKey"); ret = RegDeleteKeyA(hkey_main, "TestNewRenameKey");
todo_wine
ok(!ret, "Unexpected return value %ld.\n", ret); ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegDeleteKeyA(hkey_main, "TestRenameKey"); ret = RegDeleteKeyA(hkey_main, "TestRenameKey");
todo_wine
ok(ret, "Unexpected return value %ld.\n", ret); ok(ret, "Unexpected return value %ld.\n", ret);
/* Subkey does not exist. */ /* Subkey does not exist. */
ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL); ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL);
ok(!ret, "Unexpected return value %ld.\n", ret); ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, L"unknown_subkey", NULL); ret = RegRenameKey(key, L"unknown_subkey", NULL);
todo_wine
ok(ret == ERROR_FILE_NOT_FOUND, "Unexpected return value %ld.\n", ret); ok(ret == ERROR_FILE_NOT_FOUND, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, L"unknown_subkey", L"known_subkey"); ret = RegRenameKey(key, L"unknown_subkey", L"known_subkey");
todo_wine
ok(ret == ERROR_FILE_NOT_FOUND, "Unexpected return value %ld.\n", ret); ok(ret == ERROR_FILE_NOT_FOUND, "Unexpected return value %ld.\n", ret);
/* Rename existing subkey. */ /* Rename existing subkey. */
...@@ -4534,14 +4523,11 @@ static void test_RegRenameKey(void) ...@@ -4534,14 +4523,11 @@ static void test_RegRenameKey(void)
RegCloseKey(key2); RegCloseKey(key2);
ret = RegRenameKey(key, L"known_subkey", L"renamed_subkey"); ret = RegRenameKey(key, L"known_subkey", L"renamed_subkey");
todo_wine
ok(!ret, "Unexpected return value %ld.\n", ret); ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegDeleteKeyA(key, "renamed_subkey"); ret = RegDeleteKeyA(key, "renamed_subkey");
todo_wine
ok(!ret, "Unexpected return value %ld.\n", ret); ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegDeleteKeyA(key, "known_subkey"); ret = RegDeleteKeyA(key, "known_subkey");
todo_wine
ok(ret, "Unexpected return value %ld.\n", ret); ok(ret, "Unexpected return value %ld.\n", ret);
RegCloseKey(key); RegCloseKey(key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment