[PATCH 2/5] shlwapi: Use public definitions for WhichPlatform().

Nikolay Sivov nsivov at codeweavers.com
Mon Feb 3 01:16:08 CST 2020


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/shlwapi/ordinal.c      | 66 -------------------------------------
 dlls/shlwapi/shlwapi_main.c | 48 +++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 66 deletions(-)

diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c
index c5c4fa14ad..dd39366c80 100644
--- a/dlls/shlwapi/ordinal.c
+++ b/dlls/shlwapi/ordinal.c
@@ -2291,72 +2291,6 @@ BOOL WINAPI GUIDFromStringW(LPCWSTR idstr, CLSID *id)
     return SUCCEEDED(CLSIDFromString((LPCOLESTR)idstr, id));
 }
 
-/*************************************************************************
- *      @	[SHLWAPI.276]
- *
- * Determine if the browser is integrated into the shell, and set a registry
- * key accordingly.
- *
- * PARAMS
- *  None.
- *
- * RETURNS
- *  1, If the browser is not integrated.
- *  2, If the browser is integrated.
- *
- * NOTES
- *  The key "HKLM\Software\Microsoft\Internet Explorer\IntegratedBrowser" is
- *  either set to TRUE, or removed depending on whether the browser is deemed
- *  to be integrated.
- */
-DWORD WINAPI WhichPlatform(void)
-{
-  static const char szIntegratedBrowser[] = "IntegratedBrowser";
-  static DWORD dwState = 0;
-  HKEY hKey;
-  DWORD dwRet, dwData, dwSize;
-  HMODULE hshell32;
-
-  if (dwState)
-    return dwState;
-
-  /* If shell32 exports DllGetVersion(), the browser is integrated */
-  dwState = 1;
-  hshell32 = LoadLibraryA("shell32.dll");
-  if (hshell32)
-  {
-    FARPROC pDllGetVersion;
-    pDllGetVersion = GetProcAddress(hshell32, "DllGetVersion");
-    dwState = pDllGetVersion ? 2 : 1;
-    FreeLibrary(hshell32);
-  }
-
-  /* Set or delete the key accordingly */
-  dwRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
-                        "Software\\Microsoft\\Internet Explorer", 0,
-                         KEY_ALL_ACCESS, &hKey);
-  if (!dwRet)
-  {
-    dwRet = RegQueryValueExA(hKey, szIntegratedBrowser, 0, 0,
-                             (LPBYTE)&dwData, &dwSize);
-
-    if (!dwRet && dwState == 1)
-    {
-      /* Value exists but browser is not integrated */
-      RegDeleteValueA(hKey, szIntegratedBrowser);
-    }
-    else if (dwRet && dwState == 2)
-    {
-      /* Browser is integrated but value does not exist */
-      dwData = TRUE;
-      RegSetValueExA(hKey, szIntegratedBrowser, 0, REG_DWORD,
-                     (LPBYTE)&dwData, sizeof(dwData));
-    }
-    RegCloseKey(hKey);
-  }
-  return dwState;
-}
-
 /*************************************************************************
  *      @	[SHLWAPI.278]
  *
diff --git a/dlls/shlwapi/shlwapi_main.c b/dlls/shlwapi/shlwapi_main.c
index fc1b6d6137..af79c33cb6 100644
--- a/dlls/shlwapi/shlwapi_main.c
+++ b/dlls/shlwapi/shlwapi_main.c
@@ -108,3 +108,51 @@ HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
  WARN("pdvi->cbSize = %d, unhandled\n", pdvi2->info1.cbSize);
  return E_INVALIDARG;
 }
+
+/*************************************************************************
+ *      WhichPlatform()        [SHLWAPI.276]
+ */
+UINT WINAPI WhichPlatform(void)
+{
+    static const char szIntegratedBrowser[] = "IntegratedBrowser";
+    static DWORD state = PLATFORM_UNKNOWN;
+    DWORD ret, data, size;
+    HMODULE hshell32;
+    HKEY hKey;
+
+    if (state)
+        return state;
+
+    /* If shell32 exports DllGetVersion(), the browser is integrated */
+    state = PLATFORM_BROWSERONLY;
+    hshell32 = LoadLibraryA("shell32.dll");
+    if (hshell32)
+    {
+        FARPROC pDllGetVersion;
+        pDllGetVersion = GetProcAddress(hshell32, "DllGetVersion");
+        state = pDllGetVersion ? PLATFORM_INTEGRATED : PLATFORM_BROWSERONLY;
+        FreeLibrary(hshell32);
+    }
+
+    /* Set or delete the key accordingly */
+    ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Internet Explorer", 0, KEY_ALL_ACCESS, &hKey);
+    if (!ret)
+    {
+        size = sizeof(data);
+        ret = RegQueryValueExA(hKey, szIntegratedBrowser, 0, 0, (BYTE *)&data, &size);
+        if (!ret && state == PLATFORM_BROWSERONLY)
+        {
+            /* Value exists but browser is not integrated */
+            RegDeleteValueA(hKey, szIntegratedBrowser);
+        }
+        else if (ret && state == PLATFORM_INTEGRATED)
+        {
+            /* Browser is integrated but value does not exist */
+            data = TRUE;
+            RegSetValueExA(hKey, szIntegratedBrowser, 0, REG_DWORD, (BYTE *)&data, sizeof(data));
+        }
+        RegCloseKey(hKey);
+    }
+
+    return state;
+}
-- 
2.24.1




More information about the wine-devel mailing list