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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include <stdlib.h> /* abs() */
30 #include <sys/types.h>
35 #define NONAMELESSUNION
36 #define NONAMELESSSTRUCT
42 #include "user_private.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;
86 #define NE_RSCTYPE_ICON 0x8003
87 #define NE_RSCTYPE_GROUP_ICON 0x800e
92 static void dumpIcoDirEnty ( LPicoICONDIRENTRY entry )
94 TRACE("width = 0x%08x height = 0x%08x\n", entry->bWidth, entry->bHeight);
95 TRACE("colors = 0x%08x planes = 0x%08x\n", entry->bColorCount, entry->wPlanes);
96 TRACE("bitcount = 0x%08x bytesinres = 0x%08lx offset = 0x%08lx\n",
97 entry->wBitCount, entry->dwBytesInRes, entry->dwImageOffset);
99 static void dumpIcoDir ( LPicoICONDIR entry )
101 TRACE("type = 0x%08x count = 0x%08x\n", entry->idType, entry->idCount);
105 /**********************************************************************
108 * Find an entry by id in a resource directory
109 * Copied from loader/pe_resource.c (FIXME: should use exported resource functions)
111 static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DIRECTORY *dir,
112 WORD id, const void *root )
114 const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
117 entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
118 min = dir->NumberOfNamedEntries;
119 max = min + dir->NumberOfIdEntries - 1;
122 pos = (min + max) / 2;
123 if (entry[pos].u1.s2.Id == id)
124 return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s3.OffsetToDirectory);
125 if (entry[pos].u1.s2.Id > id) max = pos - 1;
131 /**********************************************************************
134 * Find a default entry in a resource directory
135 * Copied from loader/pe_resource.c (FIXME: should use exported resource functions)
137 static const IMAGE_RESOURCE_DIRECTORY *find_entry_default( const IMAGE_RESOURCE_DIRECTORY *dir,
140 const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
141 entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
142 return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry->u2.s3.OffsetToDirectory);
145 /*************************************************************************
146 * USER32_GetResourceTable
148 static DWORD USER32_GetResourceTable(LPBYTE peimage,DWORD pesize,LPBYTE *retptr)
150 IMAGE_DOS_HEADER * mz_header;
152 TRACE("%p %p\n", peimage, retptr);
156 mz_header = (IMAGE_DOS_HEADER*) peimage;
158 if (mz_header->e_magic != IMAGE_DOS_SIGNATURE)
160 if (mz_header->e_cblp == 1) /* .ICO file ? */
162 *retptr = (LPBYTE)-1; /* ICONHEADER.idType, must be 1 */
166 return 0; /* failed */
168 if (mz_header->e_lfanew >= pesize) {
169 return 0; /* failed, happens with PKZIP DOS Exes for instance. */
171 if (*((DWORD*)(peimage + mz_header->e_lfanew)) == IMAGE_NT_SIGNATURE )
172 return IMAGE_NT_SIGNATURE;
174 if (*((WORD*)(peimage + mz_header->e_lfanew)) == IMAGE_OS2_SIGNATURE )
176 IMAGE_OS2_HEADER * ne_header;
178 ne_header = (IMAGE_OS2_HEADER*)(peimage + mz_header->e_lfanew);
180 if (ne_header->ne_magic != IMAGE_OS2_SIGNATURE)
183 if( (ne_header->ne_restab - ne_header->ne_rsrctab) <= sizeof(NE_TYPEINFO) )
184 *retptr = (LPBYTE)-1;
186 *retptr = peimage + mz_header->e_lfanew + ne_header->ne_rsrctab;
188 return IMAGE_OS2_SIGNATURE;
190 return 0; /* failed */
192 /*************************************************************************
193 * USER32_LoadResource
195 static BYTE * USER32_LoadResource( LPBYTE peimage, NE_NAMEINFO* pNInfo, WORD sizeShift, ULONG *uSize)
197 TRACE("%p %p 0x%08x\n", peimage, pNInfo, sizeShift);
199 *uSize = (DWORD)pNInfo->length << sizeShift;
200 return peimage + ((DWORD)pNInfo->offset << sizeShift);
203 /*************************************************************************
206 static BYTE * ICO_LoadIcon( LPBYTE peimage, LPicoICONDIRENTRY lpiIDE, ULONG *uSize)
208 TRACE("%p %p\n", peimage, lpiIDE);
210 *uSize = lpiIDE->dwBytesInRes;
211 return peimage + lpiIDE->dwImageOffset;
214 /*************************************************************************
215 * ICO_GetIconDirectory
217 * Reads .ico file and build phony ICONDIR struct
219 #define HEADER_SIZE (sizeof(CURSORICONDIR) - sizeof (CURSORICONDIRENTRY))
220 #define HEADER_SIZE_FILE (sizeof(icoICONDIR) - sizeof (icoICONDIRENTRY))
222 static BYTE * ICO_GetIconDirectory( LPBYTE peimage, LPicoICONDIR* lplpiID, ULONG *uSize )
224 CURSORICONDIR * lpcid; /* icon resource in resource-dir format */
225 CURSORICONDIR * lpID; /* icon resource in resource format */
228 TRACE("%p %p\n", peimage, lplpiID);
230 lpcid = (CURSORICONDIR*)peimage;
232 if( lpcid->idReserved || (lpcid->idType != 1) || (!lpcid->idCount) )
235 /* allocate the phony ICONDIR structure */
236 *uSize = lpcid->idCount * sizeof(CURSORICONDIRENTRY) + HEADER_SIZE;
237 if( (lpID = HeapAlloc(GetProcessHeap(),0, *uSize) ))
239 /* copy the header */
240 lpID->idReserved = lpcid->idReserved;
241 lpID->idType = lpcid->idType;
242 lpID->idCount = lpcid->idCount;
244 /* copy the entries */
245 for( i=0; i < lpcid->idCount; i++ )
247 memcpy(&lpID->idEntries[i], &lpcid->idEntries[i], sizeof(CURSORICONDIRENTRY) - 2);
248 lpID->idEntries[i].wResId = i;
251 *lplpiID = (LPicoICONDIR)peimage;
257 /*************************************************************************
258 * ICO_ExtractIconExW [internal]
261 * nIcons = 0: returns number of Icons in file
266 * success: number of icons in file (nIcons = 0) or nr of icons retrieved
268 static UINT ICO_ExtractIconExW(
269 LPCWSTR lpszExeFileName,
279 UINT cx1, cx2, cy1, cy2;
283 UINT16 iconDirCount = 0,iconCount = 0;
287 WCHAR szExePath[MAX_PATH];
288 DWORD dwSearchReturn;
290 TRACE("%s, %d, %d %p 0x%08x\n", debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId, flags);
292 dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, sizeof(szExePath) / sizeof(szExePath[0]), szExePath, NULL);
293 if ((dwSearchReturn == 0) || (dwSearchReturn > sizeof(szExePath) / sizeof(szExePath[0])))
295 WARN("File %s not found or path too long\n", debugstr_w(lpszExeFileName));
299 hFile = CreateFileW(szExePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
300 if (hFile == INVALID_HANDLE_VALUE) return ret;
301 fsizel = GetFileSize(hFile,&fsizeh);
304 fmapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
308 WARN("CreateFileMapping error %d\n", GetLastError() );
312 if (!(peimage = MapViewOfFile(fmapping, FILE_MAP_READ, 0, 0, 0)))
314 WARN("MapViewOfFile error %d\n", GetLastError() );
315 CloseHandle(fmapping);
318 CloseHandle(fmapping);
320 cx1 = LOWORD(cxDesired);
321 cx2 = HIWORD(cxDesired);
322 cy1 = LOWORD(cyDesired);
323 cy2 = HIWORD(cyDesired);
325 if (pIconId) /* Invalidate first icon identifier */
326 *pIconId = 0xFFFFFFFF;
328 if (!pIconId) /* if no icon identifier array present use the icon handle array as intermediate storage */
329 pIconId = (UINT*)RetPtr;
331 sig = USER32_GetResourceTable(peimage, fsizel, &pData);
333 /* ico file or NE exe/dll*/
334 if (sig==IMAGE_OS2_SIGNATURE || sig==1) /* .ICO file */
337 NE_TYPEINFO *pTInfo = (NE_TYPEINFO*)(pData + 2);
338 NE_NAMEINFO *pIconStorage = NULL;
339 NE_NAMEINFO *pIconDir = NULL;
340 LPicoICONDIR lpiID = NULL;
343 TRACE("-- OS2/icon Signature (0x%08x)\n", sig);
345 if (pData == (BYTE*)-1)
347 pCIDir = ICO_GetIconDirectory(peimage, &lpiID, &uSize); /* check for .ICO file */
350 iconDirCount = 1; iconCount = lpiID->idCount;
351 TRACE("-- icon found %p 0x%08x 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
354 else while (pTInfo->type_id && !(pIconStorage && pIconDir))
356 if (pTInfo->type_id == NE_RSCTYPE_GROUP_ICON) /* find icon directory and icon repository */
358 iconDirCount = pTInfo->count;
359 pIconDir = ((NE_NAMEINFO*)(pTInfo + 1));
360 TRACE("\tfound directory - %i icon families\n", iconDirCount);
362 if (pTInfo->type_id == NE_RSCTYPE_ICON)
364 iconCount = pTInfo->count;
365 pIconStorage = ((NE_NAMEINFO*)(pTInfo + 1));
366 TRACE("\ttotal icons - %i\n", iconCount);
368 pTInfo = (NE_TYPEINFO *)((char*)(pTInfo+1)+pTInfo->count*sizeof(NE_NAMEINFO));
371 if ((pIconStorage && pIconDir) || lpiID) /* load resources and create icons */
376 if (lpiID) /* *.ico file, deallocate heap pointer*/
377 HeapFree(GetProcessHeap(), 0, pCIDir);
379 else if (nIconIndex < iconDirCount)
382 if (nIcons > iconDirCount - nIconIndex)
383 nIcons = iconDirCount - nIconIndex;
385 for (i = 0; i < nIcons; i++)
387 /* .ICO files have only one icon directory */
388 if (lpiID == NULL) /* not *.ico */
389 pCIDir = USER32_LoadResource(peimage, pIconDir + i + nIconIndex, *(WORD*)pData, &uSize);
390 pIconId[i] = LookupIconIdFromDirectoryEx(pCIDir, TRUE, cx1, cy1, flags);
391 if (cx2 && cy2) pIconId[++i] = LookupIconIdFromDirectoryEx(pCIDir, TRUE, cx2, cy2, flags);
393 if (lpiID) /* *.ico file, deallocate heap pointer*/
394 HeapFree(GetProcessHeap(), 0, pCIDir);
396 for (icon = 0; icon < nIcons; icon++)
400 pCIDir = ICO_LoadIcon(peimage, lpiID->idEntries + (int)pIconId[icon], &uSize);
402 for (i = 0; i < iconCount; i++)
403 if (pIconStorage[i].id == ((int)pIconId[icon] | 0x8000) )
404 pCIDir = USER32_LoadResource(peimage, pIconStorage + i, *(WORD*)pData, &uSize);
408 RetPtr[icon] = CreateIconFromResourceEx(pCIDir, uSize, TRUE, 0x00030000,
411 RetPtr[++icon] = CreateIconFromResourceEx(pCIDir, uSize, TRUE, 0x00030000,
417 ret = icon; /* return number of retrieved icons */
424 else if( sig == IMAGE_NT_SIGNATURE )
427 PIMAGE_DOS_HEADER dheader;
428 PIMAGE_NT_HEADERS pe_header;
429 PIMAGE_SECTION_HEADER pe_sections;
430 const IMAGE_RESOURCE_DIRECTORY *rootresdir,*iconresdir,*icongroupresdir;
431 const IMAGE_RESOURCE_DATA_ENTRY *idataent,*igdataent;
432 const IMAGE_RESOURCE_DIRECTORY_ENTRY *xresent;
435 dheader = (PIMAGE_DOS_HEADER)peimage;
436 pe_header = (PIMAGE_NT_HEADERS)(peimage+dheader->e_lfanew); /* it is a pe header, USER32_GetResourceTable checked that */
437 pe_sections = (PIMAGE_SECTION_HEADER)(((char*)pe_header) + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER)
438 + pe_header->FileHeader.SizeOfOptionalHeader);
441 /* search for the root resource directory */
442 for (i=0;i<pe_header->FileHeader.NumberOfSections;i++)
444 if (pe_sections[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
446 if (fsizel < pe_sections[i].PointerToRawData+pe_sections[i].SizeOfRawData) {
447 FIXME("File %s too short (section is at %d bytes, real size is %d)\n",
448 debugstr_w(lpszExeFileName),
449 pe_sections[i].PointerToRawData+pe_sections[i].SizeOfRawData,
454 /* FIXME: doesn't work when the resources are not in a separate section */
455 if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress)
457 rootresdir = (PIMAGE_RESOURCE_DIRECTORY)(peimage+pe_sections[i].PointerToRawData);
464 WARN("haven't found section for resource directory.\n");
465 goto end; /* failure */
468 /* search for the group icon directory */
469 if (!(icongroupresdir = find_entry_by_id(rootresdir, LOWORD(RT_GROUP_ICON), rootresdir)))
471 WARN("No Icongroupresourcedirectory!\n");
472 goto end; /* failure */
474 iconDirCount = icongroupresdir->NumberOfNamedEntries + icongroupresdir->NumberOfIdEntries;
476 /* only number of icons requested */
480 goto end; /* success */
485 /* search resource id */
487 int iId = abs(nIconIndex);
488 const IMAGE_RESOURCE_DIRECTORY_ENTRY* xprdeTmp = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*)(icongroupresdir+1);
490 while(n<iconDirCount && xprdeTmp)
492 if(xprdeTmp->u1.s2.Id == iId)
502 WARN("resource id %d not found\n", iId);
503 goto end; /* failure */
508 /* check nIconIndex to be in range */
509 if (nIconIndex >= iconDirCount)
511 WARN("nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
512 goto end; /* failure */
516 /* assure we don't get too much */
517 if( nIcons > iconDirCount - nIconIndex )
518 nIcons = iconDirCount - nIconIndex;
520 /* starting from specified index */
521 xresent = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*)(icongroupresdir+1) + nIconIndex;
523 for (i=0; i < nIcons; i++,xresent++)
525 const IMAGE_RESOURCE_DIRECTORY *resdir;
527 /* go down this resource entry, name */
528 resdir = (const IMAGE_RESOURCE_DIRECTORY *)((const char *)rootresdir + xresent->u2.s3.OffsetToDirectory);
530 /* default language (0) */
531 resdir = find_entry_default(resdir,rootresdir);
532 igdataent = (const IMAGE_RESOURCE_DATA_ENTRY*)resdir;
534 /* lookup address in mapped image for virtual address */
537 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++)
539 if (igdataent->OffsetToData < pe_sections[j].VirtualAddress)
541 if (igdataent->OffsetToData+igdataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
544 if (igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData+igdataent->Size > fsizel) {
545 FIXME("overflow in PE lookup (%s has len %d, have offset %d), short file?\n", debugstr_w(lpszExeFileName), fsizel,
546 igdataent->OffsetToData - pe_sections[j].VirtualAddress + pe_sections[j].PointerToRawData + igdataent->Size);
547 goto end; /* failure */
549 igdata = peimage+(igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
554 FIXME("no matching real address for icongroup!\n");
555 goto end; /* failure */
557 pIconId[i] = LookupIconIdFromDirectoryEx(igdata, TRUE, cx1, cy1, flags);
558 if (cx2 && cy2) pIconId[++i] = LookupIconIdFromDirectoryEx(igdata, TRUE, cx2, cy2, flags);
561 if (!(iconresdir=find_entry_by_id(rootresdir,LOWORD(RT_ICON),rootresdir)))
563 WARN("No Iconresourcedirectory!\n");
564 goto end; /* failure */
567 for (i=0; i<nIcons; i++)
569 const IMAGE_RESOURCE_DIRECTORY *xresdir;
570 xresdir = find_entry_by_id(iconresdir, LOWORD(pIconId[i]), rootresdir);
573 WARN("icon entry %d not found\n", LOWORD(pIconId[i]));
577 xresdir = find_entry_default(xresdir, rootresdir);
578 idataent = (const IMAGE_RESOURCE_DATA_ENTRY*)xresdir;
581 /* map virtual to address in image */
582 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++)
584 if (idataent->OffsetToData < pe_sections[j].VirtualAddress)
586 if (idataent->OffsetToData+idataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
588 idata = peimage+(idataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
592 WARN("no matching real address found for icondata!\n");
596 RetPtr[i] = CreateIconFromResourceEx(idata, idataent->Size, TRUE, 0x00030000, cx1, cy1, flags);
598 RetPtr[++i] = CreateIconFromResourceEx(idata, idataent->Size, TRUE, 0x00030000, cx2, cy2, flags);
600 ret = i; /* return number of retrieved icons */
601 } /* if(sig == IMAGE_NT_SIGNATURE) */
604 UnmapViewOfFile(peimage); /* success */
608 /***********************************************************************
609 * PrivateExtractIconsW [USER32.@]
612 * If HIWORD(sizeX) && HIWORD(sizeY) 2 * ((nIcons + 1) MOD 2) icons are
613 * returned, with the LOWORD size icon first and the HIWORD size icon
615 * Also the Windows equivalent does extract icons in a strange way if
616 * nIndex is negative. Our implementation treats a negative nIndex as
617 * looking for that resource identifier for the first icon to retrieve.
620 * should also support 16 bit EXE + DLLs, cursor and animated cursor as
621 * well as bitmap files.
624 UINT WINAPI PrivateExtractIconsW (
629 HICON * phicon, /* [out] pointer to array of nIcons HICON handles */
630 UINT* pIconId, /* [out] pointer to array of nIcons icon identifiers or NULL */
631 UINT nIcons, /* [in] number of icons to retrieve */
632 UINT flags ) /* [in] LR_* flags used by LoadImage */
634 TRACE("%s %d %dx%d %p %p %d 0x%08x\n",
635 debugstr_w(lpwstrFile), nIndex, sizeX, sizeY, phicon, pIconId, nIcons, flags);
637 if ((nIcons & 1) && HIWORD(sizeX) && HIWORD(sizeY))
639 WARN("Uneven number %d of icons requested for small and large icons!\n", nIcons);
641 return ICO_ExtractIconExW(lpwstrFile, phicon, nIndex, nIcons, sizeX, sizeY, pIconId, flags);
644 /***********************************************************************
645 * PrivateExtractIconsA [USER32.@]
648 UINT WINAPI PrivateExtractIconsA (
653 HICON * phicon, /* [out] pointer to array of nIcons HICON handles */
654 UINT* piconid, /* [out] pointer to array of nIcons icon identifiers or NULL */
655 UINT nIcons, /* [in] number of icons to retrieve */
656 UINT flags ) /* [in] LR_* flags used by LoadImage */
659 INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
660 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
662 MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len);
663 ret = PrivateExtractIconsW(lpwstrFile, nIndex, sizeX, sizeY, phicon, piconid, nIcons, flags);
665 HeapFree(GetProcessHeap(), 0, lpwstrFile);
669 /***********************************************************************
670 * PrivateExtractIconExW [USER32.@]
672 * if nIndex == -1 it returns the number of icons in any case !!!
674 UINT WINAPI PrivateExtractIconExW (
681 DWORD cyicon, cysmicon, cxicon, cxsmicon;
684 TRACE("%s %d %p %p %d\n",
685 debugstr_w(lpwstrFile),nIndex,phIconLarge, phIconSmall, nIcons);
688 /* get the number of icons */
689 return ICO_ExtractIconExW(lpwstrFile, NULL, 0, 0, 0, 0, NULL, LR_DEFAULTCOLOR);
691 if (nIcons == 1 && phIconSmall && phIconLarge)
694 cxicon = GetSystemMetrics(SM_CXICON);
695 cyicon = GetSystemMetrics(SM_CYICON);
696 cxsmicon = GetSystemMetrics(SM_CXSMICON);
697 cysmicon = GetSystemMetrics(SM_CYSMICON);
699 ret = ICO_ExtractIconExW(lpwstrFile, hIcon, nIndex, 2, cxicon | (cxsmicon<<16),
700 cyicon | (cysmicon<<16), NULL, LR_DEFAULTCOLOR);
701 *phIconLarge = hIcon[0];
702 *phIconSmall = hIcon[1];
708 /* extract n small icons */
709 cxsmicon = GetSystemMetrics(SM_CXSMICON);
710 cysmicon = GetSystemMetrics(SM_CYSMICON);
711 ret = ICO_ExtractIconExW(lpwstrFile, phIconSmall, nIndex, nIcons, cxsmicon,
712 cysmicon, NULL, LR_DEFAULTCOLOR);
716 /* extract n large icons */
717 cxicon = GetSystemMetrics(SM_CXICON);
718 cyicon = GetSystemMetrics(SM_CYICON);
719 ret = ICO_ExtractIconExW(lpwstrFile, phIconLarge, nIndex, nIcons, cxicon,
720 cyicon, NULL, LR_DEFAULTCOLOR);
725 /***********************************************************************
726 * PrivateExtractIconExA [USER32.@]
728 UINT WINAPI PrivateExtractIconExA (
736 INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
737 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
739 TRACE("%s %d %p %p %d\n", lpstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
741 MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len);
742 ret = PrivateExtractIconExW(lpwstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
743 HeapFree(GetProcessHeap(), 0, lpwstrFile);