Change return value for shell32.ExtractIconEx
Rolf Kalbermatter
rolf.kalbermatter at citeng.com
Fri Dec 6 16:06:24 CST 2002
I checked several location for the right protoype to ExtractIconEx() and
did see some inconsistencies. In an older SDK help file from Visual C 5.0
it states that this function returns a HICON just as its seemingly sibling
ExtractIcon(). However in the according headers for WinNT 4.0 the definitions
are already to return an UINT. Newer SDK documentations and headers both for
Visual C 6.0 and the MSDN online documentation do agree that this function
returns an UINT.
So here is a patch which changes that accordingly and at the same time calls
the PrivateExtractIconEx function from user32 directly since several tests
on my Win2K system show that they return indeed exactly the same parameters
for different calling scenarios (and under no circumstances anything which
could be interpreted as a HICON but always the number of extracted icon pairs
on success).
Changelog
* dlls/shell32/iconcache.c
Change the return value for ExtractIconEx from HICON to UINT and make the
function call directly user32.PrivateExtractIconEx
* include/shellapi.h
Change the return value for ExtractIconEx from HICON to UINT
retrieving revision 1.63
diff -u -r1.63 iconcache.c
--- dlls/shell32/iconcache.c 3 Dec 2002 21:35:43 -0000 1.63
+++ dlls/shell32/iconcache.c 6 Dec 2002 21:29:10 -0000
@@ -397,7 +397,7 @@
/*************************************************************************
* ExtractIconEx [SHELL32.@]
*/
-HICON WINAPI ExtractIconExAW ( LPCVOID lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons )
+UINT WINAPI ExtractIconExAW(LPCVOID lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons)
{ if (SHELL_OsIsUnicode())
return ExtractIconExW ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
return ExtractIconExA ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
@@ -407,48 +407,22 @@
* ExtractIconExW [SHELL32.@]
* RETURNS:
* 0 no icon found
- * 1 file is not valid
- * HICON handle of a icon (phiconLarge/Small == NULL)
+ * -1 file is not valid
+ * or number of icons extracted
*/
-HICON WINAPI ExtractIconExW( LPCWSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons )
+UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons)
{
- HICON ret = 0;
+ TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons);
- TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons);
-
- if (phiconLarge && !phiconSmall && nIconIndex == -1) /* Number of icons requested */
- return (HICON)PrivateExtractIconsW(lpszFile, 0, 0, 0, NULL, NULL, 0, 0);
-
- if (phiconLarge)
- {
- ret = (HICON)PrivateExtractIconsW(lpszFile, nIconIndex, 32, 32, phiconLarge, NULL, nIcons, 0);
- if (nIcons==1)
- {
- ret = phiconLarge[0];
- }
- }
-
- /* if no pointers given and one icon expected, return the handle directly */
- if (!phiconLarge && !phiconSmall && nIcons==1)
- phiconSmall = &ret;
-
- if (phiconSmall)
- {
- ret = (HICON)PrivateExtractIconsW(lpszFile, nIconIndex, 16, 16, phiconSmall, NULL, nIcons, 0);
- if (nIcons==1)
- {
- ret = phiconSmall[0];
- }
- }
- return ret;
+ return PrivateExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
}
/*************************************************************************
* ExtractIconExA [SHELL32.@]
*/
-HICON WINAPI ExtractIconExA(LPCSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons )
+UINT WINAPI ExtractIconExA(LPCSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons)
{
- HICON ret;
+ UINT ret;
INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
Index: include/shellapi.h
===================================================================
RCS file: /home/wine/wine/include/shellapi.h,v
retrieving revision 1.18
diff -u -r1.18 shellapi.h
--- include/shellapi.h 30 Nov 2002 02:22:24 -0000 1.18
+++ include/shellapi.h 6 Dec 2002 21:13:27 -0000
@@ -273,10 +273,10 @@
HICON WINAPI ExtractAssociatedIconExA(HINSTANCE,LPSTR,LPWORD,LPWORD);
HICON WINAPI ExtractAssociatedIconExW(HINSTANCE,LPWSTR,LPWORD,LPWORD);
#define ExtractAssociatedIconEx WINELIB_NAME_AW(ExtractAssociatedIconEx)
-HICON WINAPI ExtractIconExA( LPCSTR, INT, HICON *, HICON *, UINT );
-HICON WINAPI ExtractIconExW( LPCWSTR, INT, HICON *, HICON *, UINT );
+UINT WINAPI ExtractIconExA(LPCSTR,INT,HICON*,HICON*,UINT);
+UINT WINAPI ExtractIconExW(LPCWSTR,INT,HICON*,HICON*,UINT);
#define ExtractIconEx WINELIB_NAME_AW(ExtractIconEx)
-HICON WINAPI ExtractIconExAW(LPCVOID, INT, HICON *, HICON *, UINT );
+UINT WINAPI ExtractIconExAW(LPCVOID,INT,HICON*,HICON*,UINT);
HINSTANCE WINAPI FindExecutableA(LPCSTR,LPCSTR,LPSTR);
HINSTANCE WINAPI FindExecutableW(LPCWSTR,LPCWSTR,LPWSTR);
#define FindExecutable WINELIB_NAME_AW(FindExecutable)
More information about the wine-patches
mailing list