https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a69393205ad3e37c4ba286385f29644683518cd8

commit a69393205ad3e37c4ba286385f29644683518cd8
Author:     Mark Jansen <mark.jan...@reactos.org>
AuthorDate: Tue Mar 27 19:57:00 2018 +0200
Commit:     Mark Jansen <mark.jan...@reactos.org>
CommitDate: Sat Apr 7 15:29:58 2018 +0200

    [SHELL32] Partially implement SHCreateFileExtractIconW
    CORE-14082
---
 dll/win32/shell32/CExtractIcon.cpp | 36 ++++++++++++++++++++++++++++++++++++
 dll/win32/shell32/stubs.cpp        | 14 --------------
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/dll/win32/shell32/CExtractIcon.cpp 
b/dll/win32/shell32/CExtractIcon.cpp
index 232d2c212f..26bdb4e930 100644
--- a/dll/win32/shell32/CExtractIcon.cpp
+++ b/dll/win32/shell32/CExtractIcon.cpp
@@ -338,3 +338,39 @@ HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, 
void **ppv)
 {
     return ShellObjectCreator<CExtractIcon>(riid, ppv);
 }
+
+/*
+ * Partially implemented
+ * See apitests\shell32\SHCreateFileExtractIconW.cpp for details
+ * Currently (march 2018) our shell does not handle IExtractIconW with an 
invalid path,
+ * so this (wrong) implementation actually works better for us.
+ */
+EXTERN_C HRESULT
+WINAPI
+SHCreateFileExtractIconW(LPCWSTR pszPath,
+                         DWORD dwFileAttributes,
+                         REFIID riid,
+                         void **ppv)
+{
+    SHFILEINFOW shfi;
+    ULONG_PTR firet = SHGetFileInfoW(pszPath, dwFileAttributes, &shfi, 
sizeof(shfi), SHGFI_USEFILEATTRIBUTES | SHGFI_ICONLOCATION);
+    HRESULT hr = E_FAIL;
+    if (firet)
+    {
+        CComPtr<IDefaultExtractIconInit> iconInit;
+        hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit, 
&iconInit));
+        if (FAILED_UNEXPECTEDLY(hr))
+            return hr;
+
+        hr = iconInit->SetNormalIcon(shfi.szDisplayName, shfi.iIcon);
+        if (FAILED_UNEXPECTEDLY(hr))
+            return hr;
+
+        return iconInit->QueryInterface(riid, ppv);
+    }
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
+    return hr;
+}
+
diff --git a/dll/win32/shell32/stubs.cpp b/dll/win32/shell32/stubs.cpp
index 48339a6a83..f2019e5f2d 100644
--- a/dll/win32/shell32/stubs.cpp
+++ b/dll/win32/shell32/stubs.cpp
@@ -69,20 +69,6 @@ PathIsEqualOrSubFolder(LPWSTR lpFolder, LPWSTR lpSubFolder)
     return FALSE;
 }
 
-/*
- * Unimplemented
- */
-EXTERN_C HRESULT
-WINAPI
-SHCreateFileExtractIconW(LPCWSTR pszPath,
-                         DWORD dwFileAttributes,
-                         REFIID riid,
-                         void **ppv)
-{
-    FIXME("SHCreateFileExtractIconW() stub\n");
-    return E_FAIL;
-}
-
 EXTERN_C HRESULT
 WINAPI
 SHGetUnreadMailCountW(HKEY hKeyUser,

Reply via email to