Fix ANSI->Unicode calling for ExtractIconExA/W.

This commit is contained in:
Rolf Kalbermatter 2002-12-03 21:35:43 +00:00 committed by Alexandre Julliard
parent a53a988171
commit 25304d0a5e

View File

@ -402,56 +402,62 @@ HICON WINAPI ExtractIconExAW ( LPCVOID lpszFile, INT nIconIndex, HICON * phiconL
return ExtractIconExW ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons); return ExtractIconExW ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
return ExtractIconExA ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons); return ExtractIconExA ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
} }
/************************************************************************* /*************************************************************************
* ExtractIconExA [SHELL32.@] * ExtractIconExW [SHELL32.@]
* RETURNS * RETURNS:
* 0 no icon found * 0 no icon found
* 1 file is not valid * 1 file is not valid
* HICON handle of a icon (phiconLarge/Small == NULL) * HICON handle of a icon (phiconLarge/Small == NULL)
*/ */
HICON WINAPI ExtractIconExA ( LPCSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons ) HICON WINAPI ExtractIconExW( LPCWSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons )
{ HICON ret=0; {
HICON ret = 0;
TRACE("file=%s idx=%i %p %p num=%i\n", lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons ); TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons);
if (nIconIndex==-1) /* Number of icons requested */ if (phiconLarge && !phiconSmall && nIconIndex == -1) /* Number of icons requested */
return (HICON)PrivateExtractIconsA( lpszFile, -1, 0, 0, NULL, 0, 0, 0 ); return (HICON)PrivateExtractIconsW(lpszFile, 0, 0, 0, NULL, NULL, 0, 0);
if (phiconLarge) if (phiconLarge)
{ {
ret = (HICON)PrivateExtractIconsA( lpszFile, nIconIndex, 32, 32, phiconLarge, 0, nIcons, 0 ); ret = (HICON)PrivateExtractIconsW(lpszFile, nIconIndex, 32, 32, phiconLarge, NULL, nIcons, 0);
if ( nIcons==1) if (nIcons==1)
{ ret = phiconLarge[0]; {
} ret = phiconLarge[0];
} }
}
/* if no pointers given and one icon expected, return the handle directly*/ /* if no pointers given and one icon expected, return the handle directly */
if (!phiconLarge && !phiconSmall && nIcons==1 ) if (!phiconLarge && !phiconSmall && nIcons==1)
phiconSmall = &ret; phiconSmall = &ret;
if (phiconSmall) if (phiconSmall)
{ {
ret = (HICON)PrivateExtractIconsA( lpszFile, nIconIndex, 16, 16, phiconSmall, 0, nIcons, 0 ); ret = (HICON)PrivateExtractIconsW(lpszFile, nIconIndex, 16, 16, phiconSmall, NULL, nIcons, 0);
if ( nIcons==1 ) if (nIcons==1)
{ ret = phiconSmall[0]; {
} ret = phiconSmall[0];
} }
}
return ret; return ret;
} }
/************************************************************************* /*************************************************************************
* ExtractIconExW [SHELL32.@] * ExtractIconExA [SHELL32.@]
*/ */
HICON WINAPI ExtractIconExW ( LPCWSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons ) HICON WINAPI ExtractIconExA(LPCSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons )
{ LPSTR sFile; {
HICON ret; HICON ret;
INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
TRACE("file=%s idx=%i %p %p num=%i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons ); TRACE("%s %i %p %p %i\n", lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
sFile = HEAP_strdupWtoA (GetProcessHeap(),0,lpszFile); MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
ret = ExtractIconExA ( sFile, nIconIndex, phiconLarge, phiconSmall, nIcons); ret = ExtractIconExW (lpwstrFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
HeapFree(GetProcessHeap(),0,sFile); HeapFree(GetProcessHeap(), 0, lpwstrFile);
return ret; return ret;
} }
/************************************************************************* /*************************************************************************