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
42 #include "wine/winbase16.h"
43 #include "cursoricon.h"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(icon);
52 BYTE bWidth; /* Width, in pixels, of the image */
53 BYTE bHeight; /* Height, in pixels, of the image */
54 BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */
55 BYTE bReserved; /* Reserved ( must be 0) */
56 WORD wPlanes; /* Color Planes */
57 WORD wBitCount; /* Bits per pixel */
58 DWORD dwBytesInRes; /* How many bytes in this resource? */
59 DWORD dwImageOffset; /* Where in the file is this image? */
60 } icoICONDIRENTRY, *LPicoICONDIRENTRY;
64 WORD idReserved; /* Reserved (must be 0) */
65 WORD idType; /* Resource Type (RES_ICON or RES_CURSOR) */
66 WORD idCount; /* How many images */
67 icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */
68 } icoICONDIR, *LPicoICONDIR;
73 static void dumpIcoDirEnty ( LPicoICONDIRENTRY entry )
75 TRACE("width = 0x%08x height = 0x%08x\n", entry->bWidth, entry->bHeight);
76 TRACE("colors = 0x%08x planes = 0x%08x\n", entry->bColorCount, entry->wPlanes);
77 TRACE("bitcount = 0x%08x bytesinres = 0x%08lx offset = 0x%08lx\n",
78 entry->wBitCount, entry->dwBytesInRes, entry->dwImageOffset);
80 static void dumpIcoDir ( LPicoICONDIR entry )
82 TRACE("type = 0x%08x count = 0x%08x\n", entry->idType, entry->idCount);
86 /**********************************************************************
89 * Find an entry by id in a resource directory
90 * Copied from loader/pe_resource.c (FIXME: should use exported resource functions)
92 static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DIRECTORY *dir,
93 WORD id, const void *root )
95 const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
98 entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
99 min = dir->NumberOfNamedEntries;
100 max = min + dir->NumberOfIdEntries - 1;
103 pos = (min + max) / 2;
104 if (entry[pos].u1.s2.Id == id)
105 return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory);
106 if (entry[pos].u1.s2.Id > id) max = pos - 1;
112 /**********************************************************************
115 * Find a default entry in a resource directory
116 * Copied from loader/pe_resource.c (FIXME: should use exported resource functions)
118 static const IMAGE_RESOURCE_DIRECTORY *find_entry_default( const IMAGE_RESOURCE_DIRECTORY *dir,
121 const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
122 entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
123 return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry->u2.s3.OffsetToDirectory);
126 /*************************************************************************
127 * USER32_GetResourceTable
129 static DWORD USER32_GetResourceTable(LPBYTE peimage,DWORD pesize,LPBYTE *retptr)
131 IMAGE_DOS_HEADER * mz_header;
133 TRACE("%p %p\n", peimage, retptr);
137 mz_header = (IMAGE_DOS_HEADER*) peimage;
139 if (mz_header->e_magic != IMAGE_DOS_SIGNATURE)
141 if (mz_header->e_cblp == 1) /* .ICO file ? */
143 *retptr = (LPBYTE)-1; /* ICONHEADER.idType, must be 1 */
147 return 0; /* failed */
149 if (mz_header->e_lfanew >= pesize) {
150 return 0; /* failed, happens with PKZIP DOS Exes for instance. */
152 if (*((DWORD*)(peimage + mz_header->e_lfanew)) == IMAGE_NT_SIGNATURE )
153 return IMAGE_NT_SIGNATURE;
155 if (*((WORD*)(peimage + mz_header->e_lfanew)) == IMAGE_OS2_SIGNATURE )
157 IMAGE_OS2_HEADER * ne_header;
159 ne_header = (IMAGE_OS2_HEADER*)(peimage + mz_header->e_lfanew);
161 if (ne_header->ne_magic != IMAGE_OS2_SIGNATURE)
164 if( (ne_header->ne_restab - ne_header->ne_rsrctab) <= sizeof(NE_TYPEINFO) )
165 *retptr = (LPBYTE)-1;
167 *retptr = peimage + mz_header->e_lfanew + ne_header->ne_rsrctab;
169 return IMAGE_OS2_SIGNATURE;
171 return 0; /* failed */
173 /*************************************************************************
174 * USER32_LoadResource
176 static BYTE * USER32_LoadResource( LPBYTE peimage, NE_NAMEINFO* pNInfo, WORD sizeShift, ULONG *uSize)
178 TRACE("%p %p 0x%08x\n", peimage, pNInfo, sizeShift);
180 *uSize = (DWORD)pNInfo->length << sizeShift;
181 return peimage + ((DWORD)pNInfo->offset << sizeShift);
184 /*************************************************************************
187 static BYTE * ICO_LoadIcon( LPBYTE peimage, LPicoICONDIRENTRY lpiIDE, ULONG *uSize)
189 TRACE("%p %p\n", peimage, lpiIDE);
191 *uSize = lpiIDE->dwBytesInRes;
192 return peimage + lpiIDE->dwImageOffset;
195 /*************************************************************************
196 * ICO_GetIconDirectory
198 * Reads .ico file and build phony ICONDIR struct
199 * see http://www.microsoft.com/win32dev/ui/icons.htm
201 #define HEADER_SIZE (sizeof(CURSORICONDIR) - sizeof (CURSORICONDIRENTRY))
202 #define HEADER_SIZE_FILE (sizeof(icoICONDIR) - sizeof (icoICONDIRENTRY))
204 static BYTE * ICO_GetIconDirectory( LPBYTE peimage, LPicoICONDIR* lplpiID, ULONG *uSize )
206 CURSORICONDIR * lpcid; /* icon resource in resource-dir format */
207 CURSORICONDIR * lpID; /* icon resource in resource format */
210 TRACE("%p %p\n", peimage, lplpiID);
212 lpcid = (CURSORICONDIR*)peimage;
214 if( lpcid->idReserved || (lpcid->idType != 1) || (!lpcid->idCount) )
217 /* allocate the phony ICONDIR structure */
218 *uSize = lpcid->idCount * sizeof(CURSORICONDIRENTRY) + HEADER_SIZE;
219 if( (lpID = (CURSORICONDIR*)HeapAlloc(GetProcessHeap(),0, *uSize) ))
221 /* copy the header */
222 lpID->idReserved = lpcid->idReserved;
223 lpID->idType = lpcid->idType;
224 lpID->idCount = lpcid->idCount;
226 /* copy the entries */
227 for( i=0; i < lpcid->idCount; i++ )
229 memcpy((void*)&(lpID->idEntries[i]),(void*)&(lpcid->idEntries[i]), sizeof(CURSORICONDIRENTRY) - 2);
230 lpID->idEntries[i].wResId = i;
233 *lplpiID = (LPicoICONDIR)peimage;
239 /*************************************************************************
240 * ICO_ExtractIconExW [internal]
243 * nIcons = 0: returns number of Icons in file
248 * success: number of icons in file (nIcons = 0) or nr of icons retrieved
250 static UINT ICO_ExtractIconExW(
251 LPCWSTR lpszExeFileName,
261 UINT cx1, cx2, cy1, cy2;
265 UINT16 iconDirCount = 0,iconCount = 0;
270 WCHAR szExePath[MAX_PATH];
271 DWORD dwSearchReturn;
273 TRACE("%s, %d, %d %p 0x%08x\n", debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId, flags);
275 dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, sizeof(szExePath) / sizeof(szExePath[0]), szExePath, NULL);
276 if ((dwSearchReturn == 0) || (dwSearchReturn > sizeof(szExePath) / sizeof(szExePath[0])))
278 WARN("File %s not found or path too long\n", debugstr_w(lpszExeFileName));
282 hFile = CreateFileW(szExePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
283 if (hFile == INVALID_HANDLE_VALUE) return ret;
284 fsizel = GetFileSize(hFile,&fsizeh);
287 fmapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
291 WARN("CreateFileMapping error %ld\n", GetLastError() );
295 if (!(peimage = MapViewOfFile(fmapping, FILE_MAP_READ, 0, 0, 0)))
297 WARN("MapViewOfFile error %ld\n", GetLastError() );
298 CloseHandle(fmapping);
301 CloseHandle(fmapping);
303 cx1 = LOWORD(cxDesired);
304 cx2 = HIWORD(cxDesired) ? HIWORD(cxDesired) : cx1;
305 cy1 = LOWORD(cyDesired);
306 cy2 = HIWORD(cyDesired) ? HIWORD(cyDesired) : cy1;
308 if (pIconId) /* Invalidate first icon identifier */
309 *pIconId = 0xFFFFFFFF;
311 if (!pIconId) /* if no icon identifier array present use the icon handle array as intermediate storage */
312 pIconId = (UINT*)RetPtr;
314 sig = USER32_GetResourceTable(peimage, fsizel, &pData);
316 /* ico file or NE exe/dll*/
317 if (sig==IMAGE_OS2_SIGNATURE || sig==1) /* .ICO file */
320 NE_TYPEINFO *pTInfo = (NE_TYPEINFO*)(pData + 2);
321 NE_NAMEINFO *pIconStorage = NULL;
322 NE_NAMEINFO *pIconDir = NULL;
323 LPicoICONDIR lpiID = NULL;
325 TRACE("-- OS2/icon Signature (0x%08lx)\n", sig);
327 if (pData == (BYTE*)-1)
329 pCIDir = ICO_GetIconDirectory(peimage, &lpiID, &uSize); /* check for .ICO file */
332 iconDirCount = 1; iconCount = lpiID->idCount;
333 TRACE("-- icon found %p 0x%08lx 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
336 else while (pTInfo->type_id && !(pIconStorage && pIconDir))
338 if (pTInfo->type_id == NE_RSCTYPE_GROUP_ICON) /* find icon directory and icon repository */
340 iconDirCount = pTInfo->count;
341 pIconDir = ((NE_NAMEINFO*)(pTInfo + 1));
342 TRACE("\tfound directory - %i icon families\n", iconDirCount);
344 if (pTInfo->type_id == NE_RSCTYPE_ICON)
346 iconCount = pTInfo->count;
347 pIconStorage = ((NE_NAMEINFO*)(pTInfo + 1));
348 TRACE("\ttotal icons - %i\n", iconCount);
350 pTInfo = (NE_TYPEINFO *)((char*)(pTInfo+1)+pTInfo->count*sizeof(NE_NAMEINFO));
353 if ((pIconStorage && pIconDir) || lpiID) /* load resources and create icons */
358 if (lpiID && pCIDir) /* *.ico file, deallocate heap pointer*/
359 HeapFree(GetProcessHeap(), 0, pCIDir);
361 else if (nIconIndex < iconDirCount)
364 if (nIcons > iconDirCount - nIconIndex)
365 nIcons = iconDirCount - nIconIndex;
367 for (i = 0; i < nIcons; i++)
369 /* .ICO files have only one icon directory */
370 if (lpiID == NULL) /* not *.ico */
371 pCIDir = USER32_LoadResource(peimage, pIconDir + i + nIconIndex, *(WORD*)pData, &uSize);
372 pIconId[i] = LookupIconIdFromDirectoryEx(pCIDir, TRUE, (i & 1) ? cx2 : cx1, (i & 1) ? cy2 : cy1, flags);
374 if (lpiID && pCIDir) /* *.ico file, deallocate heap pointer*/
375 HeapFree(GetProcessHeap(), 0, pCIDir);
377 for (icon = 0; icon < nIcons; icon++)
381 pCIDir = ICO_LoadIcon(peimage, lpiID->idEntries + (int)pIconId[icon], &uSize);
383 for (i = 0; i < iconCount; i++)
384 if (pIconStorage[i].id == ((int)pIconId[icon] | 0x8000) )
385 pCIDir = USER32_LoadResource(peimage, pIconStorage + i, *(WORD*)pData, &uSize);
388 RetPtr[icon] = (HICON)CreateIconFromResourceEx(pCIDir, uSize, TRUE, 0x00030000,
389 (icon & 1) ? cx2 : cx1, (icon & 1) ? cy2 : cy1, flags);
393 ret = icon; /* return number of retrieved icons */
400 else if( sig == IMAGE_NT_SIGNATURE )
403 PIMAGE_DOS_HEADER dheader;
404 PIMAGE_NT_HEADERS pe_header;
405 PIMAGE_SECTION_HEADER pe_sections;
406 const IMAGE_RESOURCE_DIRECTORY *rootresdir,*iconresdir,*icongroupresdir;
407 const IMAGE_RESOURCE_DATA_ENTRY *idataent,*igdataent;
408 const IMAGE_RESOURCE_DIRECTORY_ENTRY *xresent;
411 dheader = (PIMAGE_DOS_HEADER)peimage;
412 pe_header = (PIMAGE_NT_HEADERS)(peimage+dheader->e_lfanew); /* it is a pe header, USER32_GetResourceTable checked that */
413 pe_sections = (PIMAGE_SECTION_HEADER)(((char*)pe_header) + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER)
414 + pe_header->FileHeader.SizeOfOptionalHeader);
417 /* search for the root resource directory */
418 for (i=0;i<pe_header->FileHeader.NumberOfSections;i++)
420 if (pe_sections[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
422 if (fsizel < pe_sections[i].PointerToRawData+pe_sections[i].SizeOfRawData) {
423 FIXME("File %s too short (section is at %ld bytes, real size is %ld)\n",
424 debugstr_w(lpszExeFileName),
425 pe_sections[i].PointerToRawData+pe_sections[i].SizeOfRawData,
430 /* FIXME: doesn't work when the resources are not in a separate section */
431 if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress)
433 rootresdir = (PIMAGE_RESOURCE_DIRECTORY)(peimage+pe_sections[i].PointerToRawData);
440 WARN("haven't found section for resource directory.\n");
441 goto end; /* failure */
444 /* search for the group icon directory */
445 if (!(icongroupresdir = find_entry_by_id(rootresdir, LOWORD(RT_GROUP_ICON), rootresdir)))
447 WARN("No Icongroupresourcedirectory!\n");
448 goto end; /* failure */
450 iconDirCount = icongroupresdir->NumberOfNamedEntries + icongroupresdir->NumberOfIdEntries;
452 /* only number of icons requested */
456 goto end; /* success */
461 /* search resource id */
463 int iId = abs(nIconIndex);
464 PIMAGE_RESOURCE_DIRECTORY_ENTRY xprdeTmp = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(icongroupresdir+1);
466 while(n<iconDirCount && xprdeTmp)
468 if(xprdeTmp->u1.s2.Id == iId)
478 WARN("resource id %d not found\n", iId);
479 goto end; /* failure */
484 /* check nIconIndex to be in range */
485 if (nIconIndex >= iconDirCount)
487 WARN("nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
488 goto end; /* failure */
492 /* assure we don't get too much */
493 if( nIcons > iconDirCount - nIconIndex )
494 nIcons = iconDirCount - nIconIndex;
496 /* starting from specified index */
497 xresent = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(icongroupresdir+1) + nIconIndex;
499 for (i=0; i < nIcons; i++,xresent++)
501 const IMAGE_RESOURCE_DIRECTORY *resdir;
503 /* go down this resource entry, name */
504 resdir = (PIMAGE_RESOURCE_DIRECTORY)((DWORD)rootresdir+(xresent->u2.s3.OffsetToDirectory));
506 /* default language (0) */
507 resdir = find_entry_default(resdir,rootresdir);
508 igdataent = (PIMAGE_RESOURCE_DATA_ENTRY)resdir;
510 /* lookup address in mapped image for virtual address */
513 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++)
515 if (igdataent->OffsetToData < pe_sections[j].VirtualAddress)
517 if (igdataent->OffsetToData+igdataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
520 if (igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData+igdataent->Size > fsizel) {
521 FIXME("overflow in PE lookup (%s has len %ld, have offset %ld), short file?\n", debugstr_w(lpszExeFileName), fsizel,
522 igdataent->OffsetToData - pe_sections[j].VirtualAddress + pe_sections[j].PointerToRawData + igdataent->Size);
523 goto end; /* failure */
525 igdata = peimage+(igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
530 FIXME("no matching real address for icongroup!\n");
531 goto end; /* failure */
533 pIconId[i] = LookupIconIdFromDirectoryEx(igdata, TRUE, (i & 1) ? cx2 : cx1, (i & 1) ? cy2 : cy1, flags);
536 if (!(iconresdir=find_entry_by_id(rootresdir,LOWORD(RT_ICON),rootresdir)))
538 WARN("No Iconresourcedirectory!\n");
539 goto end; /* failure */
542 for (i=0; i<nIcons; i++)
544 const IMAGE_RESOURCE_DIRECTORY *xresdir;
545 xresdir = find_entry_by_id(iconresdir, LOWORD(pIconId[i]), rootresdir);
546 xresdir = find_entry_default(xresdir, rootresdir);
547 idataent = (PIMAGE_RESOURCE_DATA_ENTRY)xresdir;
550 /* map virtual to address in image */
551 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++)
553 if (idataent->OffsetToData < pe_sections[j].VirtualAddress)
555 if (idataent->OffsetToData+idataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
557 idata = peimage+(idataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
561 WARN("no matching real address found for icondata!\n");
565 RetPtr[i] = (HICON) CreateIconFromResourceEx(idata,idataent->Size,TRUE,0x00030000,
566 (i & 1) ? cx2 : cx1, (i & 1) ? cy2 : cy1, flags);
568 ret = i; /* return number of retrieved icons */
569 } /* if(sig == IMAGE_NT_SIGNATURE) */
572 UnmapViewOfFile(peimage); /* success */
576 /***********************************************************************
577 * PrivateExtractIconsW [USER32.@]
580 * If HIWORD(sizeX) && HIWORD(sizeY) 2 * ((nIcons + 1) MOD 2) icons are
581 * returned, with the LOWORD size icon first and the HIWORD size icon
583 * Also the Windows equivalent does extract icons in a strange way if
584 * nIndex is negative. Our implementation treats a negative nIndex as
585 * looking for that resource identifier for the first icon to retrieve.
588 * should also support 16 bit EXE + DLLs, cursor and animated cursor as
589 * well as bitmap files.
592 UINT WINAPI PrivateExtractIconsW (
597 HICON * phicon, /* [out] pointer to array of nIcons HICON handles */
598 UINT* pIconId, /* [out] pointer to array of nIcons icon identifiers or NULL */
599 UINT nIcons, /* [in] number of icons to retrieve */
600 UINT flags ) /* [in] LR_* flags used by LoadImage */
602 TRACE("%s %d %dx%d %p %p %d 0x%08x\n",
603 debugstr_w(lpwstrFile), nIndex, sizeX, sizeY, phicon, pIconId, nIcons, flags);
605 if ((nIcons & 1) && HIWORD(sizeX) && HIWORD(sizeY))
607 WARN("Uneven number %d of icons requested for small and large icons!\n", nIcons);
609 return ICO_ExtractIconExW(lpwstrFile, phicon, nIndex, nIcons, sizeX, sizeY, pIconId, flags);
612 /***********************************************************************
613 * PrivateExtractIconsA [USER32.@]
616 UINT WINAPI PrivateExtractIconsA (
621 HICON * phicon, /* [out] pointer to array of nIcons HICON handles */
622 UINT* piconid, /* [out] pointer to array of nIcons icon identifiers or NULL */
623 UINT nIcons, /* [in] number of icons to retrieve */
624 UINT flags ) /* [in] LR_* flags used by LoadImage */
627 INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
628 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
630 MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len);
631 ret = PrivateExtractIconsW(lpwstrFile, nIndex, sizeX, sizeY, phicon, piconid, nIcons, flags);
633 HeapFree(GetProcessHeap(), 0, lpwstrFile);
637 /***********************************************************************
638 * PrivateExtractIconExW [USER32.@]
640 * if nIndex == -1 it returns the number of icons in any case !!!
642 UINT WINAPI PrivateExtractIconExW (
649 DWORD cyicon, cysmicon, cxicon, cxsmicon;
652 TRACE("%s %d %p %p %d\n",
653 debugstr_w(lpwstrFile),nIndex,phIconLarge, phIconSmall, nIcons);
656 /* get the number of icons */
657 return ICO_ExtractIconExW(lpwstrFile, NULL, 0, 0, 0, 0, NULL, LR_DEFAULTCOLOR);
659 if (nIcons == 1 && phIconSmall && phIconLarge)
662 cxicon = GetSystemMetrics(SM_CXICON);
663 cyicon = GetSystemMetrics(SM_CYICON);
664 cxsmicon = GetSystemMetrics(SM_CXSMICON);
665 cysmicon = GetSystemMetrics(SM_CYSMICON);
667 ret = ICO_ExtractIconExW(lpwstrFile, (HICON*) &hIcon, nIndex, 2, cxicon | (cxsmicon<<16),
668 cyicon | (cysmicon<<16), NULL, LR_DEFAULTCOLOR);
669 *phIconLarge = hIcon[0];
670 *phIconSmall = hIcon[1];
676 /* extract n small icons */
677 cxsmicon = GetSystemMetrics(SM_CXSMICON);
678 cysmicon = GetSystemMetrics(SM_CYSMICON);
679 ret = ICO_ExtractIconExW(lpwstrFile, phIconSmall, nIndex, nIcons, cxsmicon,
680 cysmicon, NULL, LR_DEFAULTCOLOR);
684 /* extract n large icons */
685 cxicon = GetSystemMetrics(SM_CXICON);
686 cyicon = GetSystemMetrics(SM_CYICON);
687 ret = ICO_ExtractIconExW(lpwstrFile, phIconLarge, nIndex, nIcons, cxicon,
688 cyicon, NULL, LR_DEFAULTCOLOR);
693 /***********************************************************************
694 * PrivateExtractIconExA [USER32.@]
696 UINT WINAPI PrivateExtractIconExA (
704 INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
705 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
707 TRACE("%s %d %p %p %d\n", lpstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
709 MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len);
710 ret = PrivateExtractIconExW(lpwstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
711 HeapFree(GetProcessHeap(), 0, lpwstrFile);