[SHELL32] Follow-up of #2076 (#2091)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Tue, 26 Nov 2019 12:45:58 +0000 (21:45 +0900)
committerGitHub <noreply@github.com>
Tue, 26 Nov 2019 12:45:58 +0000 (21:45 +0900)
Fix EXE and SCR file icons. CORE-16533

dll/win32/shell32/CExtractIcon.cpp
dll/win32/shell32/folders/CFSFolder.cpp

index e24f6c1..26bdb4e 100644 (file)
@@ -138,21 +138,6 @@ HRESULT STDMETHODCALLTYPE CExtractIcon::SetNormalIcon(
 {
     TRACE("(%p, %s, %d)\n", this, debugstr_w(pszFile), iIcon);
 
-    if (lstrcmpiW(PathFindExtensionW(pszFile), L".exe") == 0)
-    {
-        if (!PrivateExtractIconExW(pszFile, 0, NULL, NULL, 1))
-        {
-            WCHAR szPath[MAX_PATH];
-            GetModuleFileNameW(shell32_hInstance, szPath, _countof(szPath));
-            DuplicateString(szPath, &normalIcon.file);
-            if (!normalIcon.file)
-                return E_OUTOFMEMORY;
-
-            normalIcon.index = -IDI_SHELL_EXE;
-            return S_OK;
-        }
-    }
-
     DuplicateString(pszFile, &normalIcon.file);
     if (!normalIcon.file)
         return E_OUTOFMEMORY;
index 6acf301..493eeea 100644 (file)
@@ -312,6 +312,13 @@ HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, RE
             {
                 ILGetDisplayNameExW(psf, pidl, wTemp, ILGDN_FORPARSING);
                 icon_idx = 0;
+
+                INT ret = ExtractIconExW(wTemp, -1, NULL, NULL, 0);
+                if (ret <= 0)
+                {
+                    StringCbCopyW(wTemp, sizeof(wTemp), swShell32Name);
+                    icon_idx = -IDI_SHELL_EXE;
+                }
             }
 
             initIcon->SetNormalIcon(wTemp, icon_idx);