shlwapi: Invoke RegGetValue on SHRegGetValue call.
authorPiotr Caban <piotr@codeweavers.com>
Sun, 31 Jan 2010 22:03:09 +0000 (23:03 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 1 Feb 2010 11:10:01 +0000 (12:10 +0100)
dlls/shlwapi/reg.c
dlls/shlwapi/shlwapi.spec
dlls/shlwapi/tests/shreg.c

index 55952badb9fd04f8d272f3490cd613f4b4018701..d641955ba05b9f217cb01acab5d38af69decfef9 100644 (file)
@@ -1137,68 +1137,6 @@ DWORD WINAPI SHGetValueA(HKEY hKey, LPCSTR lpszSubKey, LPCSTR lpszValue,
   return dwRet;
 }
 
-/*************************************************************************
- * SHRegGetValueA   [SHLWAPI.@]
- *
- * Get a value from the registry.
- *
- * PARAMS
- *   hKey       [I] Handle to registry key
- *   lpszSubKey [I] Name of sub key containing value to get
- *   lpszValue  [I] Name of value to get
- *   srrf       [I] Flags for restricting returned data
- *   pwType     [O] Pointer to the values type
- *   pvData     [O] Pointer to the values data
- *   pcbData    [O] Pointer to the values size
- *
- * RETURNS
- *   Success: ERROR_SUCCESS. Output parameters contain the details read.
- *   Failure: An error code from RegOpenKeyExA() or SHQueryValueExA().
- */
-LSTATUS WINAPI SHRegGetValueA(HKEY hKey, LPCSTR lpszSubKey, LPCSTR lpszValue, SRRF srrfFlags,
-                         LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
-{
-  DWORD dwRet = 0;
-  HKEY hSubKey = 0;
-
-  TRACE("(hkey=%p,%s,%s,%p,%p,%p)\n", hKey, debugstr_a(lpszSubKey),
-        debugstr_a(lpszValue), pwType, pvData, pcbData);
-  FIXME("Semi-Stub: Find meaning and implement handling of SRFF Flags 0x%08x\n", srrfFlags);
-
-  dwRet = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_QUERY_VALUE, &hSubKey);
-  if (! dwRet)
-  {
-    /* SHQueryValueEx expands Environment strings */
-    dwRet = SHQueryValueExA(hSubKey, lpszValue, 0, pwType, pvData, pcbData);
-    RegCloseKey(hSubKey);
-  }
-  return dwRet;
-}
-
-/*************************************************************************
- * SHReg GetRegValueW   [SHLWAPI.@]
- *
- * See SHGetValueA.
- */
-LSTATUS WINAPI SHRegGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, SRRF srrfFlags,
-                         LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
-{
-  DWORD dwRet = 0;
-  HKEY hSubKey = 0;
-
-  TRACE("(hkey=%p,%s,%s,0x%08x, %p,%p,%p)\n", hKey, debugstr_w(lpszSubKey),
-        debugstr_w(lpszValue), srrfFlags,pwType, pvData, pcbData);
-  FIXME("Semi-Stub: Find meaning and implement handling of SRFF Flags 0x%08x\n", srrfFlags);
-
-  dwRet = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_QUERY_VALUE, &hSubKey);
-  if (! dwRet)
-  {
-    dwRet = SHQueryValueExW(hSubKey, lpszValue, 0, pwType, pvData, pcbData);
-    RegCloseKey(hSubKey);
-  }
-  return dwRet;
-}
-
 /*************************************************************************
  * SHGetValueW   [SHLWAPI.@]
  *
index 165a50cab39925418ab04767de7e845d4f0f0b3b..479443c3e5e04fb62e5da4c07c3334834cd74e25 100644 (file)
 @ stdcall SHRegGetPathW(long wstr wstr ptr long)
 @ stdcall SHRegGetUSValueA ( str str ptr ptr ptr long ptr long )
 @ stdcall SHRegGetUSValueW ( wstr wstr ptr ptr ptr long ptr long )
-@ stdcall SHRegGetValueA ( long str str long ptr ptr ptr )
-@ stdcall SHRegGetValueW ( long wstr wstr long ptr ptr ptr )
+@ stdcall SHRegGetValueA ( long str str long ptr ptr ptr ) advapi32.RegGetValueA
+@ stdcall SHRegGetValueW ( long wstr wstr long ptr ptr ptr ) advapi32.RegGetValueW
 @ stdcall SHRegOpenUSKeyA ( str long long long long )
 @ stdcall SHRegOpenUSKeyW ( wstr long long long long )
 @ stdcall SHRegQueryInfoUSKeyA ( long ptr ptr ptr ptr long )
index 00cec4fc30c3ecbebcc56ca39442238f8bb62ded..5fb3dacf14f37123161baa91f1f1c384b97e444a 100644 (file)
@@ -38,6 +38,8 @@ typedef DWORD (WINAPI *SHCopyKeyA_func)(HKEY,LPCSTR,HKEY,DWORD);
 static SHCopyKeyA_func pSHCopyKeyA;
 typedef DWORD (WINAPI *SHRegGetPathA_func)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD);
 static SHRegGetPathA_func pSHRegGetPathA;
+typedef LSTATUS (WINAPI *SHRegGetValueA_func)(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD);
+static SHRegGetValueA_func pSHRegGetValueA;
 
 static char sTestpath1[] = "%LONGSYSTEMVAR%\\subdir1";
 static char sTestpath2[] = "%FOO%\\subdir1";
@@ -138,6 +140,44 @@ static void test_SHGetValue(void)
        ok( REG_SZ == dwType , "Expected REG_SZ, got (%u)\n", dwType);
 }
 
+static void test_SHRegGetValue(void)
+{
+    LSTATUS ret;
+    DWORD size, type;
+    char data[MAX_PATH];
+
+    if(!pSHRegGetValueA)
+        return;
+
+    size = MAX_PATH;
+    ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_EXPAND_SZ, &type, data, &size);
+    ok(ret == ERROR_INVALID_PARAMETER, "SHRegGetValue failed, ret=%u\n", ret);
+
+    size = MAX_PATH;
+    ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_SZ, &type, data, &size);
+    ok(ret == ERROR_SUCCESS, "SHRegGetValue failed, ret=%u\n", ret);
+    ok(!strcmp(data, sExpTestpath1), "data = %s, expected %s\n", data, sExpTestpath1);
+    ok(type == REG_SZ, "type = %d, expected REG_SZ\n", type);
+
+    size = MAX_PATH;
+    ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_DWORD, &type, data, &size);
+    ok(ret == ERROR_UNSUPPORTED_TYPE, "SHRegGetValue failed, ret=%u\n", ret);
+
+    size = MAX_PATH;
+    ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_EXPAND_SZ, &type, data, &size);
+    ok(ret == ERROR_INVALID_PARAMETER, "SHRegGetValue failed, ret=%u\n", ret);
+
+    size = MAX_PATH;
+    ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_SZ, &type, data, &size);
+    ok(ret == ERROR_SUCCESS, "SHRegGetValue failed, ret=%u\n", ret);
+    ok(!strcmp(data, sTestpath1), "data = %s, expected %s\n", data, sTestpath1);
+    ok(type == REG_SZ, "type = %d, expected REG_SZ\n", type);
+
+    size = MAX_PATH;
+    ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_QWORD, &type, data, &size);
+    ok(ret == ERROR_UNSUPPORTED_TYPE, "SHRegGetValue failed, ret=%u\n", ret);
+}
+
 static void test_SHGetRegPath(void)
 {
        char buf[MAX_PATH];
@@ -414,7 +454,9 @@ START_TEST(shreg)
        hshlwapi = GetModuleHandleA("shlwapi.dll");
         pSHCopyKeyA=(SHCopyKeyA_func)GetProcAddress(hshlwapi,"SHCopyKeyA");
         pSHRegGetPathA=(SHRegGetPathA_func)GetProcAddress(hshlwapi,"SHRegGetPathA");
+        pSHRegGetValueA=(SHRegGetValueA_func)GetProcAddress(hshlwapi,"SHRegGetValueA");
        test_SHGetValue();
+        test_SHRegGetValue();
        test_SHQUeryValueEx();
        test_SHGetRegPath();
        test_SHCopyKey();