[SHELL32][SDK] Implement SHGetShellStyleHInstance (#5707)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Thu, 21 Sep 2023 00:22:33 +0000 (09:22 +0900)
committerGitHub <noreply@github.com>
Thu, 21 Sep 2023 00:22:33 +0000 (09:22 +0900)
Co-authored-by: Oleg Dubinskiy <oleg.dubinskij30@gmail.com>
This PR supersedes PR #3851.
- Implement SHGetShellStyleHInstance function.
- Add SHGetShellStyleHInstance prototype to <shlobj.h>.
CORE-17707

dll/win32/shell32/stubs.cpp
dll/win32/shell32/utils.cpp
sdk/include/psdk/shlobj.h

index a49a506..a048e2c 100644 (file)
@@ -1202,14 +1202,3 @@ DWORD WINAPI SHGetComputerDisplayNameW(DWORD param1, DWORD param2, DWORD param3,
     FIXME("SHGetComputerDisplayNameW() stub\n");
     return E_FAIL;
 }
-
-/*
- * Unimplemented
- */
-EXTERN_C HINSTANCE
-WINAPI
-SHGetShellStyleHInstance(VOID)
-{
-    FIXME("SHGetShellStyleHInstance() stub\n");
-    return NULL;
-}
index 4140fca..edb1f64 100644 (file)
@@ -9,6 +9,48 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(shell);
 
+/*************************************************************************
+ *                SHGetShellStyleHInstance (SHELL32.749)
+ */
+EXTERN_C HINSTANCE
+WINAPI
+SHGetShellStyleHInstance(VOID)
+{
+    HINSTANCE hInst = NULL;
+    WCHAR szPath[MAX_PATH], szColorName[100];
+    HRESULT hr;
+    CStringW strShellStyle;
+
+    TRACE("SHGetShellStyleHInstance called\n");
+
+    /* First, attempt to load the shellstyle dll from the current active theme */
+    hr = GetCurrentThemeName(szPath, _countof(szPath), szColorName, _countof(szColorName), NULL, 0);
+    if (FAILED(hr))
+        goto DoDefault;
+
+    /* Strip the theme filename */
+    PathRemoveFileSpecW(szPath);
+
+    strShellStyle = szPath;
+    strShellStyle += L"\\Shell\\";
+    strShellStyle += szColorName;
+    strShellStyle += L"\\ShellStyle.dll";
+
+    hInst = LoadLibraryExW(strShellStyle, NULL, LOAD_LIBRARY_AS_DATAFILE);
+    if (hInst)
+        return hInst;
+
+    /* Otherwise, use the version stored in the System32 directory */
+DoDefault:
+    if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\System32\\ShellStyle.dll",
+                                   szPath, _countof(szPath)))
+    {
+        ERR("Expand failed\n");
+        return NULL;
+    }
+    return LoadLibraryExW(szPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
+}
+
 /*************************************************************************
  *                SHCreatePropertyBag (SHELL32.715)
  */
index 26745ce..601fd58 100644 (file)
@@ -336,6 +336,10 @@ SHOpenFolderAndSelectItems(
 
 int WINAPI PathCleanupSpec(_In_opt_ LPCWSTR, _Inout_ LPWSTR);
 
+#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP) && (_WIN32_WINNT <= _WIN32_WINNT_WS03)
+HINSTANCE WINAPI SHGetShellStyleHInstance(VOID);
+#endif
+
 /*****************************************************************************
  * IContextMenu interface
  */