[PATCH] shlwapi/tests: Correctly cleanup the registry after the test

Detlef Riekenberg wine.dev at web.de
Wed Sep 17 10:47:35 CDT 2008


---
 dlls/shlwapi/tests/shreg.c |   53 ++++++++++++++++++++++++++-----------------
 1 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/dlls/shlwapi/tests/shreg.c b/dlls/shlwapi/tests/shreg.c
index 77a47e2..5b45fad 100644
--- a/dlls/shlwapi/tests/shreg.c
+++ b/dlls/shlwapi/tests/shreg.c
@@ -51,12 +51,21 @@ static DWORD nExpLen1;
 static DWORD nExpLen2;
 
 static const char * sEmptyBuffer ="0123456789";
+static DWORD disposition;
 
+/* ############### */
 /* delete key and all its subkeys */
-static DWORD delete_key( HKEY hkey, LPCSTR parent, LPCSTR keyname )
+static DWORD delete_key( HKEY hkey )
 {
     HKEY parentKey;
     DWORD ret;
+    LPSTR parent = "Software\\Wine";
+    LPSTR keyname = "Test";
+
+    if (disposition == REG_CREATED_NEW_KEY) {
+        parent = "Software";
+        keyname = "Wine";
+    }
 
     RegCloseKey(hkey);
 
@@ -73,15 +82,17 @@ static DWORD delete_key( HKEY hkey, LPCSTR parent, LPCSTR keyname )
 
 static HKEY create_test_entries(void)
 {
-	HKEY hKey;
-        DWORD ret;
-        DWORD nExpectedLen1, nExpectedLen2;
+    HKEY hKey;
+    DWORD ret;
+    DWORD nExpectedLen1, nExpectedLen2;
+
+    SetEnvironmentVariableA("LONGSYSTEMVAR", sEnvvar1);
+    SetEnvironmentVariableA("FOO", sEnvvar2);
 
-        SetEnvironmentVariableA("LONGSYSTEMVAR", sEnvvar1);
-        SetEnvironmentVariableA("FOO", sEnvvar2);
+    ret = RegCreateKeyExA(HKEY_CURRENT_USER, REG_TEST_KEY, 0, NULL, 
+                        REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,&hKey, &disposition);
 
-        ret = RegCreateKeyA(HKEY_CURRENT_USER, REG_TEST_KEY, &hKey);
-	ok( ERROR_SUCCESS == ret, "RegCreateKeyA failed, ret=%u\n", ret);
+    ok( ERROR_SUCCESS == ret, "RegCreateKeyExA failed with %u\n", ret);
 
 	if (hKey)
 	{
@@ -378,17 +389,17 @@ static void test_SHDeleteKey(void)
 
 START_TEST(shreg)
 {
-	HKEY hkey = create_test_entries();
-
-        if (!hkey) return;
-
-	hshlwapi = GetModuleHandleA("shlwapi.dll");
-        pSHCopyKeyA=(SHCopyKeyA_func)GetProcAddress(hshlwapi,"SHCopyKeyA");
-        pSHRegGetPathA=(SHRegGetPathA_func)GetProcAddress(hshlwapi,"SHRegGetPathA");
-	test_SHGetValue();
-	test_SHQUeryValueEx();
-	test_SHGetRegPath();
-	test_SHCopyKey();
-        test_SHDeleteKey();
-        delete_key( hkey, "Software\\Wine", "Test" );
+    HKEY hkey = create_test_entries();
+
+    if (!hkey) return;
+
+    hshlwapi = GetModuleHandleA("shlwapi.dll");
+    pSHCopyKeyA=(SHCopyKeyA_func)GetProcAddress(hshlwapi,"SHCopyKeyA");
+    pSHRegGetPathA=(SHRegGetPathA_func)GetProcAddress(hshlwapi,"SHRegGetPathA");
+    test_SHGetValue();
+    test_SHQUeryValueEx();
+    test_SHGetRegPath();
+    test_SHCopyKey();
+    test_SHDeleteKey();
+    delete_key( hkey );
 }
-- 
1.5.4.3


--=-LHWxsYibCwwBbJAIjKui--




More information about the wine-patches mailing list