4 * taken and slightly changed from shell
5 * this should replace the icon extraction code in shell32 and shell16 once
6 * it needs a serious test for compliance with the native API
8 * Copyright 2000 Juergen Schmied
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <stdlib.h> /* abs() */
30 #include <sys/types.h>
35 #define NONAMELESSUNION
36 #define NONAMELESSSTRUCT
41 #include "wine/winbase16.h"
42 #include "cursoricon.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(icon);
51 BYTE bWidth; /* Width, in pixels, of the image */
52 BYTE bHeight; /* Height, in pixels, of the image */
53 BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */
54 BYTE bReserved; /* Reserved ( must be 0) */
55 WORD wPlanes; /* Color Planes */
56 WORD wBitCount; /* Bits per pixel */
57 DWORD dwBytesInRes; /* How many bytes in this resource? */
58 DWORD dwImageOffset; /* Where in the file is this image? */
59 } icoICONDIRENTRY, *LPicoICONDIRENTRY;
63 WORD idReserved; /* Reserved (must be 0) */
64 WORD idType; /* Resource Type (RES_ICON or RES_CURSOR) */
65 WORD idCount; /* How many images */
66 icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */
67 } icoICONDIR, *LPicoICONDIR;
72 static void dumpIcoDirEnty ( LPicoICONDIRENTRY entry )
74 TRACE("width = 0x%08x height = 0x%08x\n", entry->bWidth, entry->bHeight);
75 TRACE("colors = 0x%08x planes = 0x%08x\n", entry->bColorCount, entry->wPlanes);
76 TRACE("bitcount = 0x%08x bytesinres = 0x%08lx offset = 0x%08lx\n",
77 entry->wBitCount, entry->dwBytesInRes, entry->dwImageOffset);
79 static void dumpIcoDir ( LPicoICONDIR entry )
81 TRACE("type = 0x%08x count = 0x%08x\n", entry->idType, entry->idCount);
85 /**********************************************************************
88 * Find an entry by id in a resource directory
89 * Copied from loader/pe_resource.c (FIXME: should use exported resource functions)
91 static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DIRECTORY *dir,
92 WORD id, const void *root )
94 const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
97 entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
98 min = dir->NumberOfNamedEntries;
99 max = min + dir->NumberOfIdEntries - 1;
102 pos = (min + max) / 2;
103 if (entry[pos].u1.s2.Id == id)
104 return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory);
105 if (entry[pos].u1.s2.Id > id) max = pos - 1;
111 /**********************************************************************
114 * Find a default entry in a resource directory
115 * Copied from loader/pe_resource.c (FIXME: should use exported resource functions)
117 static const IMAGE_RESOURCE_DIRECTORY *find_entry_default( const IMAGE_RESOURCE_DIRECTORY *dir,
120 const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
121 entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
122 return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry->u2.s3.OffsetToDirectory);
125 /*************************************************************************
126 * USER32_GetResourceTable
128 static DWORD USER32_GetResourceTable(LPBYTE peimage,DWORD pesize,LPBYTE *retptr)
130 IMAGE_DOS_HEADER * mz_header;
132 TRACE("%p %p\n", peimage, retptr);
136 mz_header = (IMAGE_DOS_HEADER*) peimage;
138 if (mz_header->e_magic != IMAGE_DOS_SIGNATURE)
140 if (mz_header->e_cblp == 1) /* .ICO file ? */
142 *retptr = (LPBYTE)-1; /* ICONHEADER.idType, must be 1 */
146 return 0; /* failed */
148 if (mz_header->e_lfanew >= pesize) {
149 return 0; /* failed, happens with PKZIP DOS Exes for instance. */
151 if (*((DWORD*)(peimage + mz_header->e_lfanew)) == IMAGE_NT_SIGNATURE )
152 return IMAGE_NT_SIGNATURE;
154 if (*((WORD*)(peimage + mz_header->e_lfanew)) == IMAGE_OS2_SIGNATURE )
156 IMAGE_OS2_HEADER * ne_header;
158 ne_header = (IMAGE_OS2_HEADER*)(peimage + mz_header->e_lfanew);
160 if (ne_header->ne_magic != IMAGE_OS2_SIGNATURE)
163 if( (ne_header->ne_restab - ne_header->ne_rsrctab) <= sizeof(NE_TYPEINFO) )
164 *retptr = (LPBYTE)-1;
166 *retptr = peimage + mz_header->e_lfanew + ne_header->ne_rsrctab;
168 return IMAGE_OS2_SIGNATURE;
170 return 0; /* failed */
172 /*************************************************************************
173 * USER32_LoadResource
175 static BYTE * USER32_LoadResource( LPBYTE peimage, NE_NAMEINFO* pNInfo, WORD sizeShift, ULONG *uSize)
177 TRACE("%p %p 0x%08x\n", peimage, pNInfo, sizeShift);
179 *uSize = (DWORD)pNInfo->length << sizeShift;
180 return peimage + ((DWORD)pNInfo->offset << sizeShift);
183 /*************************************************************************
186 static BYTE * ICO_LoadIcon( LPBYTE peimage, LPicoICONDIRENTRY lpiIDE, ULONG *uSize)
188 TRACE("%p %p\n", peimage, lpiIDE);
190 *uSize = lpiIDE->dwBytesInRes;
191 return peimage + lpiIDE->dwImageOffset;
194 /*************************************************************************
195 * ICO_GetIconDirectory
197 * Reads .ico file and build phony ICONDIR struct
198 * see http://www.microsoft.com/win32dev/ui/icons.htm
200 #define HEADER_SIZE (sizeof(CURSORICONDIR) - sizeof (CURSORICONDIRENTRY))
201 #define HEADER_SIZE_FILE (sizeof(icoICONDIR) - sizeof (icoICONDIRENTRY))
203 static BYTE * ICO_GetIconDirectory( LPBYTE peimage, LPicoICONDIR* lplpiID, ULONG *uSize )
205 CURSORICONDIR * lpcid; /* icon resource in resource-dir format */
206 CURSORICONDIR * lpID; /* icon resource in resource format */
209 TRACE("%p %p\n", peimage, lplpiID);
211 lpcid = (CURSORICONDIR*)peimage;
213 if( lpcid->idReserved || (lpcid->idType != 1) || (!lpcid->idCount) )
216 /* allocate the phony ICONDIR structure */
217 *uSize = lpcid->idCount * sizeof(CURSORICONDIRENTRY) + HEADER_SIZE;
218 if( (lpID = (CURSORICONDIR*)HeapAlloc(GetProcessHeap(),0, *uSize) ))
220 /* copy the header */
221 lpID->idReserved = lpcid->idReserved;
222 lpID->idType = lpcid->idType;
223 lpID->idCount = lpcid->idCount;
225 /* copy the entries */
226 for( i=0; i < lpcid->idCount; i++ )
228 memcpy((void*)&(lpID->idEntries[i]),(void*)&(lpcid->idEntries[i]), sizeof(CURSORICONDIRENTRY) - 2);
229 lpID->idEntries[i].wResId = i;
232 *lplpiID = (LPicoICONDIR)peimage;
238 /*************************************************************************
239 * ICO_ExtractIconExW [internal]
242 * nIcons = 0: returns number of Icons in file
247 * success: number of icons in file (nIcons = 0) or nr of icons retrieved
249 static UINT ICO_ExtractIconExW(
250 LPCWSTR lpszExeFileName,
260 UINT cx1, cx2, cy1, cy2;
264 UINT16 iconDirCount = 0,iconCount = 0;
269 WCHAR szExePath[MAX_PATH];
270 DWORD dwSearchReturn;
272 TRACE("%s, %d, %d %p 0x%08x\n", debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId, flags);
274 dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, sizeof(szExePath) / sizeof(szExePath[0]), szExePath, NULL);
275 if ((dwSearchReturn == 0) || (dwSearchReturn > sizeof(szExePath) / sizeof(szExePath[0])))
277 WARN("File %s not found or path too long\n", debugstr_w(lpszExeFileName));
281 hFile = CreateFileW(szExePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
282 if (hFile == INVALID_HANDLE_VALUE) return ret;
283 fsizel = GetFileSize(hFile,&fsizeh);
286 fmapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
290 WARN("CreateFileMapping error %ld\n", GetLastError() );
294 if (!(peimage = MapViewOfFile(fmapping, FILE_MAP_READ, 0, 0, 0)))
296 WARN("MapViewOfFile error %ld\n", GetLastError() );
297 CloseHandle(fmapping);
300 CloseHandle(fmapping);
302 cx1 = LOWORD(cxDesired);
303 cx2 = HIWORD(cxDesired) ? HIWORD(cxDesired) : cx1;
304 cy1 = LOWORD(cyDesired);
305 cy2 = HIWORD(cyDesired) ? HIWORD(cyDesired) : cy1;
307 if (pIconId) /* Invalidate first icon identifier */
308 *pIconId = 0xFFFFFFFF;
310 if (!pIconId) /* if no icon identifier array present use the icon handle array as intermediate storage */
311 pIconId = (UINT*)RetPtr;
313 sig = USER32_GetResourceTable(peimage, fsizel, &pData);
315 /* ico file or NE exe/dll*/
316 if (sig==IMAGE_OS2_SIGNATURE || sig==1) /* .ICO file */
319 NE_TYPEINFO *pTInfo = (NE_TYPEINFO*)(pData + 2);
320 NE_NAMEINFO *pIconStorage = NULL;
321 NE_NAMEINFO *pIconDir = NULL;
322 LPicoICONDIR lpiID = NULL;
324 TRACE("-- OS2/icon Signature (0x%08lx)\n", sig);
326 if (pData == (BYTE*)-1)
328 pCIDir = ICO_GetIconDirectory(peimage, &lpiID, &uSize); /* check for .ICO file */
331 iconDirCount = 1; iconCount = lpiID->idCount;
332 TRACE("-- icon found %p 0x%08lx 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
335 else while (pTInfo->type_id && !(pIconStorage && pIconDir))
337 if (pTInfo->type_id == NE_RSCTYPE_GROUP_ICON) /* find icon directory and icon repository */
339 iconDirCount = pTInfo->count;
340 pIconDir = ((NE_NAMEINFO*)(pTInfo + 1));
341 TRACE("\tfound directory - %i icon families\n", iconDirCount);
343 if (pTInfo->type_id == NE_RSCTYPE_ICON)
345 iconCount = pTInfo->count;
346 pIconStorage = ((NE_NAMEINFO*)(pTInfo + 1));
347 TRACE("\ttotal icons - %i\n", iconCount);
349 pTInfo = (NE_TYPEINFO *)((char*)(pTInfo+1)+pTInfo->count*sizeof(NE_NAMEINFO));
352 if ((pIconStorage && pIconDir) || lpiID) /* load resources and create icons */
357 if (lpiID && pCIDir) /* *.ico file, deallocate heap pointer*/
358 HeapFree(GetProcessHeap(), 0, pCIDir);
360 else if (nIconIndex < iconDirCount)
363 if (nIcons > iconDirCount - nIconIndex)
364 nIcons = iconDirCount - nIconIndex;
366 for (i = 0; i < nIcons; i++)
368 /* .ICO files have only one icon directory */
369 if (lpiID == NULL) /* not *.ico */
370 pCIDir = USER32_LoadResource(peimage, pIconDir + i + nIconIndex, *(WORD*)pData, &uSize);
371 pIconId[i] = LookupIconIdFromDirectoryEx(pCIDir, TRUE, (i & 1) ? cx2 : cx1, (i & 1) ? cy2 : cy1, flags);
373 if (lpiID && pCIDir) /* *.ico file, deallocate heap pointer*/
374 HeapFree(GetProcessHeap(), 0, pCIDir);
376 for (icon = 0; icon < nIcons; icon++)
380 pCIDir = ICO_LoadIcon(peimage, lpiID->idEntries + (int)pIconId[icon], &uSize);
382 for (i = 0; i < iconCount; i++)
383 if (pIconStorage[i].id == ((int)pIconId[icon] | 0x8000) )
384 pCIDir = USER32_LoadResource(peimage, pIconStorage + i, *(WORD*)pData, &uSize);
387 RetPtr[icon] = (HICON)CreateIconFromResourceEx(pCIDir, uSize, TRUE, 0x00030000,
388 (icon & 1) ? cx2 : cx1, (icon & 1) ? cy2 : cy1, flags);
392 ret = icon; /* return number of retrieved icons */
399 else if( sig == IMAGE_NT_SIGNATURE )
402 PIMAGE_DOS_HEADER dheader;
403 PIMAGE_NT_HEADERS pe_header;
404 PIMAGE_SECTION_HEADER pe_sections;
405 const IMAGE_RESOURCE_DIRECTORY *rootresdir,*iconresdir,*icongroupresdir;
406 const IMAGE_RESOURCE_DATA_ENTRY *idataent,*igdataent;
407 const IMAGE_RESOURCE_DIRECTORY_ENTRY *xresent;
410 dheader = (PIMAGE_DOS_HEADER)peimage;
411 pe_header = (PIMAGE_NT_HEADERS)(peimage+dheader->e_lfanew); /* it is a pe header, USER32_GetResourceTable checked that */
412 pe_sections = (PIMAGE_SECTION_HEADER)(((char*)pe_header) + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER)
413 + pe_header->FileHeader.SizeOfOptionalHeader);
416 /* search for the root resource directory */
417 for (i=0;i<pe_header->FileHeader.NumberOfSections;i++)
419 if (pe_sections[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
421 if (fsizel < pe_sections[i].PointerToRawData+pe_sections[i].SizeOfRawData) {
422 FIXME("File %s too short (section is at %ld bytes, real size is %ld)\n",
423 debugstr_w(lpszExeFileName),
424 pe_sections[i].PointerToRawData+pe_sections[i].SizeOfRawData,
429 /* FIXME: doesn't work when the resources are not in a separate section */
430 if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress)
432 rootresdir = (PIMAGE_RESOURCE_DIRECTORY)(peimage+pe_sections[i].PointerToRawData);
439 WARN("haven't found section for resource directory.\n");
440 goto end; /* failure */
443 /* search for the group icon directory */
444 if (!(icongroupresdir = find_entry_by_id(rootresdir, LOWORD(RT_GROUP_ICON), rootresdir)))
446 WARN("No Icongroupresourcedirectory!\n");
447 goto end; /* failure */
449 iconDirCount = icongroupresdir->NumberOfNamedEntries + icongroupresdir->NumberOfIdEntries;
451 /* only number of icons requested */
455 goto end; /* success */
460 /* search resource id */
462 int iId = abs(nIconIndex);
463 const IMAGE_RESOURCE_DIRECTORY_ENTRY* xprdeTmp = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*)(icongroupresdir+1);
465 while(n<iconDirCount && xprdeTmp)
467 if(xprdeTmp->u1.s2.Id == iId)
477 WARN("resource id %d not found\n", iId);
478 goto end; /* failure */
483 /* check nIconIndex to be in range */
484 if (nIconIndex >= iconDirCount)
486 WARN("nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
487 goto end; /* failure */
491 /* assure we don't get too much */
492 if( nIcons > iconDirCount - nIconIndex )
493 nIcons = iconDirCount - nIconIndex;
495 /* starting from specified index */
496 xresent = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*)(icongroupresdir+1) + nIconIndex;
498 for (i=0; i < nIcons; i++,xresent++)
500 const IMAGE_RESOURCE_DIRECTORY *resdir;
502 /* go down this resource entry, name */
503 resdir = (PIMAGE_RESOURCE_DIRECTORY)((DWORD)rootresdir+(xresent->u2.s3.OffsetToDirectory));
505 /* default language (0) */
506 resdir = find_entry_default(resdir,rootresdir);
507 igdataent = (const IMAGE_RESOURCE_DATA_ENTRY*)resdir;
509 /* lookup address in mapped image for virtual address */
512 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++)
514 if (igdataent->OffsetToData < pe_sections[j].VirtualAddress)
516 if (igdataent->OffsetToData+igdataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
519 if (igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData+igdataent->Size > fsizel) {
520 FIXME("overflow in PE lookup (%s has len %ld, have offset %ld), short file?\n", debugstr_w(lpszExeFileName), fsizel,
521 igdataent->OffsetToData - pe_sections[j].VirtualAddress + pe_sections[j].PointerToRawData + igdataent->Size);
522 goto end; /* failure */
524 igdata = peimage+(igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
529 FIXME("no matching real address for icongroup!\n");
530 goto end; /* failure */
532 pIconId[i] = LookupIconIdFromDirectoryEx(igdata, TRUE, (i & 1) ? cx2 : cx1, (i & 1) ? cy2 : cy1, flags);
535 if (!(iconresdir=find_entry_by_id(rootresdir,LOWORD(RT_ICON),rootresdir)))
537 WARN("No Iconresourcedirectory!\n");
538 goto end; /* failure */
541 for (i=0; i<nIcons; i++)
543 const IMAGE_RESOURCE_DIRECTORY *xresdir;
544 xresdir = find_entry_by_id(iconresdir, LOWORD(pIconId[i]), rootresdir);
547 WARN("icon entry %d not found\n", LOWORD(pIconId[i]));
551 xresdir = find_entry_default(xresdir, rootresdir);
552 idataent = (const IMAGE_RESOURCE_DATA_ENTRY*)xresdir;
555 /* map virtual to address in image */
556 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++)
558 if (idataent->OffsetToData < pe_sections[j].VirtualAddress)
560 if (idataent->OffsetToData+idataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
562 idata = peimage+(idataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
566 WARN("no matching real address found for icondata!\n");
570 RetPtr[i] = (HICON) CreateIconFromResourceEx(idata,idataent->Size,TRUE,0x00030000,
571 (i & 1) ? cx2 : cx1, (i & 1) ? cy2 : cy1, flags);
573 ret = i; /* return number of retrieved icons */
574 } /* if(sig == IMAGE_NT_SIGNATURE) */
577 UnmapViewOfFile(peimage); /* success */
581 /***********************************************************************
582 * PrivateExtractIconsW [USER32.@]
585 * If HIWORD(sizeX) && HIWORD(sizeY) 2 * ((nIcons + 1) MOD 2) icons are
586 * returned, with the LOWORD size icon first and the HIWORD size icon
588 * Also the Windows equivalent does extract icons in a strange way if
589 * nIndex is negative. Our implementation treats a negative nIndex as
590 * looking for that resource identifier for the first icon to retrieve.
593 * should also support 16 bit EXE + DLLs, cursor and animated cursor as
594 * well as bitmap files.
597 UINT WINAPI PrivateExtractIconsW (
602 HICON * phicon, /* [out] pointer to array of nIcons HICON handles */
603 UINT* pIconId, /* [out] pointer to array of nIcons icon identifiers or NULL */
604 UINT nIcons, /* [in] number of icons to retrieve */
605 UINT flags ) /* [in] LR_* flags used by LoadImage */
607 TRACE("%s %d %dx%d %p %p %d 0x%08x\n",
608 debugstr_w(lpwstrFile), nIndex, sizeX, sizeY, phicon, pIconId, nIcons, flags);
610 if ((nIcons & 1) && HIWORD(sizeX) && HIWORD(sizeY))
612 WARN("Uneven number %d of icons requested for small and large icons!\n", nIcons);
614 return ICO_ExtractIconExW(lpwstrFile, phicon, nIndex, nIcons, sizeX, sizeY, pIconId, flags);
617 /***********************************************************************
618 * PrivateExtractIconsA [USER32.@]
621 UINT WINAPI PrivateExtractIconsA (
626 HICON * phicon, /* [out] pointer to array of nIcons HICON handles */
627 UINT* piconid, /* [out] pointer to array of nIcons icon identifiers or NULL */
628 UINT nIcons, /* [in] number of icons to retrieve */
629 UINT flags ) /* [in] LR_* flags used by LoadImage */
632 INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
633 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
635 MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len);
636 ret = PrivateExtractIconsW(lpwstrFile, nIndex, sizeX, sizeY, phicon, piconid, nIcons, flags);
638 HeapFree(GetProcessHeap(), 0, lpwstrFile);
642 /***********************************************************************
643 * PrivateExtractIconExW [USER32.@]
645 * if nIndex == -1 it returns the number of icons in any case !!!
647 UINT WINAPI PrivateExtractIconExW (
654 DWORD cyicon, cysmicon, cxicon, cxsmicon;
657 TRACE("%s %d %p %p %d\n",
658 debugstr_w(lpwstrFile),nIndex,phIconLarge, phIconSmall, nIcons);
661 /* get the number of icons */
662 return ICO_ExtractIconExW(lpwstrFile, NULL, 0, 0, 0, 0, NULL, LR_DEFAULTCOLOR);
664 if (nIcons == 1 && phIconSmall && phIconLarge)
667 cxicon = GetSystemMetrics(SM_CXICON);
668 cyicon = GetSystemMetrics(SM_CYICON);
669 cxsmicon = GetSystemMetrics(SM_CXSMICON);
670 cysmicon = GetSystemMetrics(SM_CYSMICON);
672 ret = ICO_ExtractIconExW(lpwstrFile, (HICON*) &hIcon, nIndex, 2, cxicon | (cxsmicon<<16),
673 cyicon | (cysmicon<<16), NULL, LR_DEFAULTCOLOR);
674 *phIconLarge = hIcon[0];
675 *phIconSmall = hIcon[1];
681 /* extract n small icons */
682 cxsmicon = GetSystemMetrics(SM_CXSMICON);
683 cysmicon = GetSystemMetrics(SM_CYSMICON);
684 ret = ICO_ExtractIconExW(lpwstrFile, phIconSmall, nIndex, nIcons, cxsmicon,
685 cysmicon, NULL, LR_DEFAULTCOLOR);
689 /* extract n large icons */
690 cxicon = GetSystemMetrics(SM_CXICON);
691 cyicon = GetSystemMetrics(SM_CYICON);
692 ret = ICO_ExtractIconExW(lpwstrFile, phIconLarge, nIndex, nIcons, cxicon,
693 cyicon, NULL, LR_DEFAULTCOLOR);
698 /***********************************************************************
699 * PrivateExtractIconExA [USER32.@]
701 UINT WINAPI PrivateExtractIconExA (
709 INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
710 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
712 TRACE("%s %d %p %p %d\n", lpstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
714 MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len);
715 ret = PrivateExtractIconExW(lpwstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
716 HeapFree(GetProcessHeap(), 0, lpwstrFile);