Use SHDeleteKey to remove leftover keys from the shreg tests.

This commit is contained in:
James Hawkins 2004-11-10 01:30:59 +00:00 committed by Alexandre Julliard
parent b98b7dd65d
commit 0fec65d6a7
1 changed files with 14 additions and 16 deletions

View File

@ -51,24 +51,22 @@ static unsigned sExpLen2;
static const char * sEmptyBuffer ="0123456789"; static const char * sEmptyBuffer ="0123456789";
/* delete key and all its subkeys */ /* delete key and all its subkeys */
static DWORD delete_key( HKEY hkey ) static DWORD delete_key( HKEY hkey, LPSTR parent, LPSTR keyname )
{ {
WCHAR name[MAX_PATH]; HKEY parentKey;
DWORD ret; DWORD ret;
while (!(ret = RegEnumKeyW(hkey, 0, name, sizeof(name)))) RegCloseKey(hkey);
{
HKEY tmp; /* open the parent of the key to close */
if (!(ret = RegOpenKeyExW( hkey, name, 0, KEY_ENUMERATE_SUB_KEYS, &tmp ))) ret = RegOpenKeyEx( HKEY_CURRENT_USER, parent, 0, KEY_ALL_ACCESS, &parentKey);
{ if (ret != ERROR_SUCCESS)
ret = delete_key( tmp ); return ret;
RegCloseKey( tmp );
} ret = SHDeleteKey( parentKey, keyname );
if (ret) break; RegCloseKey(parentKey);
}
if (ret != ERROR_NO_MORE_ITEMS) return ret; return ret;
RegDeleteKeyA( hkey, NULL );
return 0;
} }
static HKEY create_test_entries(void) static HKEY create_test_entries(void)
@ -321,5 +319,5 @@ START_TEST(shreg)
test_SHGetRegPath(); test_SHGetRegPath();
test_SHCopyKey(); test_SHCopyKey();
test_SHDeleteKey(); test_SHDeleteKey();
delete_key( hkey ); delete_key( hkey, "Software\\Wine", "Test" );
} }