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

commit d7722f39fb687da5b81d36f5e043af135c7c97e1
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Thu Dec 30 17:32:35 2021 +0100
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Fri Dec 31 02:30:58 2021 +0100

    [PSDK][SHELL32][SHELLEXT] Add SHCreateFileExtractIconW() to the PSDK and 
SAL-annotate it. (#4223)
    
    Note that even if the MS PSDK and MSDN documents an hypothetical
    ANSI version SHCreateFileExtractIconA(), this one never existed
    exported in any Windows version!
---
 dll/shellext/fontext/CFontExt.cpp   |  5 -----
 dll/shellext/zipfldr/CZipFolder.hpp |  4 ----
 dll/win32/shell32/CExtractIcon.cpp  | 15 ++++++++-------
 sdk/include/psdk/shlobj.h           | 22 ++++++++++++++++++++++
 4 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/dll/shellext/fontext/CFontExt.cpp 
b/dll/shellext/fontext/CFontExt.cpp
index 7fffa90736e..30a62919bb4 100644
--- a/dll/shellext/fontext/CFontExt.cpp
+++ b/dll/shellext/fontext/CFontExt.cpp
@@ -42,11 +42,6 @@ static FolderViewColumns g_ColumnDefs[] =
 };
 
 
-
-// Should fix our headers..
-EXTERN_C HRESULT WINAPI SHCreateFileExtractIconW(LPCWSTR pszPath, DWORD 
dwFileAttributes, REFIID riid, void **ppv);
-
-
 // Helper functions to translate a guid to a readable name
 bool GetInterfaceName(const WCHAR* InterfaceString, WCHAR* buf, size_t size)
 {
diff --git a/dll/shellext/zipfldr/CZipFolder.hpp 
b/dll/shellext/zipfldr/CZipFolder.hpp
index e89aeb81d87..29644d95c2b 100644
--- a/dll/shellext/zipfldr/CZipFolder.hpp
+++ b/dll/shellext/zipfldr/CZipFolder.hpp
@@ -5,10 +5,6 @@
  * COPYRIGHT:   Copyright 2017 Mark Jansen ([email protected])
  */
 
-
-EXTERN_C HRESULT WINAPI SHCreateFileExtractIconW(LPCWSTR pszPath, DWORD 
dwFileAttributes, REFIID riid, void **ppv);
-
-
 struct FolderViewColumns
 {
     int iResource;
diff --git a/dll/win32/shell32/CExtractIcon.cpp 
b/dll/win32/shell32/CExtractIcon.cpp
index 26bdb4e9307..e82dfec4999 100644
--- a/dll/win32/shell32/CExtractIcon.cpp
+++ b/dll/win32/shell32/CExtractIcon.cpp
@@ -345,15 +345,17 @@ HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, 
void **ppv)
  * 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
+EXTERN_C
+HRESULT
 WINAPI
-SHCreateFileExtractIconW(LPCWSTR pszPath,
-                         DWORD dwFileAttributes,
-                         REFIID riid,
-                         void **ppv)
+SHCreateFileExtractIconW(
+    _In_ LPCWSTR pszFile,
+    _In_ DWORD dwFileAttributes,
+    _In_ REFIID riid,
+    _Outptr_ void **ppv)
 {
     SHFILEINFOW shfi;
-    ULONG_PTR firet = SHGetFileInfoW(pszPath, dwFileAttributes, &shfi, 
sizeof(shfi), SHGFI_USEFILEATTRIBUTES | SHGFI_ICONLOCATION);
+    ULONG_PTR firet = SHGetFileInfoW(pszFile, dwFileAttributes, &shfi, 
sizeof(shfi), SHGFI_USEFILEATTRIBUTES | SHGFI_ICONLOCATION);
     HRESULT hr = E_FAIL;
     if (firet)
     {
@@ -373,4 +375,3 @@ SHCreateFileExtractIconW(LPCWSTR pszPath,
 
     return hr;
 }
-
diff --git a/sdk/include/psdk/shlobj.h b/sdk/include/psdk/shlobj.h
index f8be3e7d299..9f7b215bff8 100644
--- a/sdk/include/psdk/shlobj.h
+++ b/sdk/include/psdk/shlobj.h
@@ -2091,6 +2091,28 @@ SHBindToParent(
   _Outptr_ LPVOID *ppv,
   _Outptr_opt_ PCUITEMID_CHILD *ppidlLast);
 
+/****************************************************************************
+ * SHCreateFileExtractIcon API
+ */
+#if (NTDDI_VERSION >= NTDDI_WINXP)
+
+// NOTE: Even if documented on MSDN, the SHCreateFileExtractIconA()
+// ANSI function never existed on Windows!
+
+HRESULT
+WINAPI
+SHCreateFileExtractIconW(
+    _In_ LPCWSTR pszFile,
+    _In_ DWORD dwFileAttributes,
+    _In_ REFIID riid,
+    _Outptr_ void **ppv);
+
+#ifdef UNICODE
+#define SHCreateFileExtractIcon  SHCreateFileExtractIconW
+#endif
+
+#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
+
 /****************************************************************************
 * SHDefExtractIcon API
 */

Reply via email to