shell32:ExtractIconEx{AW}
Rolf Kalbermatter
rolf.kalbermatter at citeng.com
Sun Dec 1 16:54:16 CST 2002
ChangeLog:
* dlls/shell32/iconcache.c
- Fix ANSI->Unicode calling for ExtractIconExA/W
License: X11/LGPL
Rolf Kalbermatter
Index: dlls/shell32/iconcache.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/iconcache.c,v
retrieving revision 1.62
diff -u -r1.62 iconcache.c
--- dlls/shell32/iconcache.c 30 Nov 2002 02:22:24 -0000 1.62
+++ dlls/shell32/iconcache.c 1 Dec 2002 22:47:22 -0000
@@ -402,56 +402,62 @@
return ExtractIconExW ( lpszFile, nIconIndex, phiconLarge, phiconSmall,
nIcons);
return ExtractIconExA ( lpszFile, nIconIndex, phiconLarge, phiconSmall,
nIcons);
}
+
/*************************************************************************
* ExtractIconExA [SHELL32.@]
* RETURNS
* 0 no icon found
- * 1 file is not valid
+ * 1 file is not valid,
* HICON handle of a icon (phiconLarge/Small == NULL)
*/
-HICON WINAPI ExtractIconExA ( LPCSTR lpszFile, INT nIconIndex, HICON *
phiconLarge, HICON * phiconSmall, UINT nIcons )
-{ HICON ret=0;
-
- TRACE("file=%s idx=%i %p %p num=%i\n", lpszFile, nIconIndex, phiconLarge,
phiconSmall, nIcons );
+HICON WINAPI ExtractIconExW ( LPCWSTR lpszFile, INT nIconIndex, HICON *
phiconLarge, HICON * phiconSmall, UINT nIcons )
+{
+ HICON ret=0;
- if (nIconIndex==-1) /* Number of icons requested */
- return (HICON)PrivateExtractIconsA( lpszFile, -1, 0, 0, NULL, 0, 0,
0 );
+ TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge,
phiconSmall, nIcons );
- if (phiconLarge)
- {
- ret = (HICON)PrivateExtractIconsA( lpszFile, nIconIndex, 32, 32,
phiconLarge, 0, 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)PrivateExtractIconsA( lpszFile, nIconIndex, 16, 16,
phiconSmall, 0, nIcons, 0 );
- if ( nIcons==1 )
- { ret = phiconSmall[0];
- }
- }
+ if (nIconIndex==-1) /* Number of icons requested */
+ return (HICON)PrivateExtractIconsW( lpszFile, -1, 0, 0, NULL, 0, 0,
0 );
- return ret;
+ if (phiconLarge)
+ {
+ ret = (HICON)PrivateExtractIconsW( lpszFile, nIconIndex, 32, 32,
phiconLarge, 0, 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, 0, nIcons, 0 );
+ if (nIcons==1 )
+ {
+ ret = phiconSmall[0];
+ }
+ }
+ return ret;
}
+
/*************************************************************************
- * ExtractIconExW [SHELL32.@]
+ * ExtractIconExA [SHELL32.@]
*/
-HICON WINAPI ExtractIconExW ( LPCWSTR lpszFile, INT nIconIndex, HICON *
phiconLarge, HICON * phiconSmall, UINT nIcons )
-{ LPSTR sFile;
- HICON ret;
-
- TRACE("file=%s idx=%i %p %p num=%i\n", debugstr_w(lpszFile), nIconIndex,
phiconLarge, phiconSmall, nIcons );
-
- sFile = HEAP_strdupWtoA (GetProcessHeap(),0,lpszFile);
- ret = ExtractIconExA ( sFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
- HeapFree(GetProcessHeap(),0,sFile);
- return ret;
+HICON WINAPI ExtractIconExA(LPCSTR lpszFile, INT nIconIndex, HICON *
phiconLarge, HICON * phiconSmall, UINT nIcons )
+{
+ HICON ret;
+ INT len = MultiByteToWideChar( CP_ACP, 0, lpszFile, -1, NULL, 0 );
+ LPWSTR lpwstrFile = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+
+ TRACE("%s %i %p %p %i\n", lpszFile, nIconIndex, phiconLarge, phiconSmall,
nIcons );
+
+ MultiByteToWideChar( CP_ACP, 0, lpszFile, -1, lpwstrFile, len );
+ ret = ExtractIconExW ( lpwstrFile, nIconIndex, phiconLarge, phiconSmall,
nIcons );
+ HeapFree( GetProcessHeap(), 0, lpwstrFile );
+ return ret;
}
/*************************************************************************
More information about the wine-patches
mailing list