1 | /* $Id: iconcache.cpp,v 1.2 1999-10-09 11:17:00 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * shell icon cache (SIC)
|
---|
4 | *
|
---|
5 | */
|
---|
6 | #include <string.h>
|
---|
7 | #include <odin.h>
|
---|
8 |
|
---|
9 | #define ICOM_CINTERFACE 1
|
---|
10 | #define CINTERFACE 1
|
---|
11 |
|
---|
12 | #include "winbase.h"
|
---|
13 | #include "winuser.h"
|
---|
14 | #include "wingdi.h"
|
---|
15 | //#include "wine/winuser16.h"
|
---|
16 | //#include "wine/winbase16.h"
|
---|
17 | //#include "neexe.h"
|
---|
18 | #include "cursoricon.h"
|
---|
19 | #include "module.h"
|
---|
20 | #include "heap.h"
|
---|
21 | #include "debugtools.h"
|
---|
22 | #include "winversion.h"
|
---|
23 |
|
---|
24 | #include "shellapi.h"
|
---|
25 | #include "pidl.h"
|
---|
26 | #include "shell32_main.h"
|
---|
27 |
|
---|
28 | #include <heapstring.h>
|
---|
29 | #include <misc.h>
|
---|
30 |
|
---|
31 | DEFAULT_DEBUG_CHANNEL(shell)
|
---|
32 |
|
---|
33 | #include "pshpack1.h"
|
---|
34 |
|
---|
35 | typedef struct
|
---|
36 | {
|
---|
37 | BYTE bWidth; /* Width, in pixels, of the image */
|
---|
38 | BYTE bHeight; /* Height, in pixels, of the image */
|
---|
39 | BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */
|
---|
40 | BYTE bReserved; /* Reserved ( must be 0) */
|
---|
41 | WORD wPlanes; /* Color Planes */
|
---|
42 | WORD wBitCount; /* Bits per pixel */
|
---|
43 | DWORD dwBytesInRes; /* How many bytes in this resource? */
|
---|
44 | DWORD dwImageOffset; /* Where in the file is this image? */
|
---|
45 | } icoICONDIRENTRY, *LPicoICONDIRENTRY;
|
---|
46 |
|
---|
47 | typedef struct
|
---|
48 | {
|
---|
49 | WORD idReserved; /* Reserved (must be 0) */
|
---|
50 | WORD idType; /* Resource Type (RES_ICON or RES_CURSOR) */
|
---|
51 | WORD idCount; /* How many images */
|
---|
52 | icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */
|
---|
53 | } icoICONDIR, *LPicoICONDIR;
|
---|
54 |
|
---|
55 | #include "poppack.h"
|
---|
56 |
|
---|
57 | #if 0
|
---|
58 | static void dumpIcoDirEnty ( LPicoICONDIRENTRY entry )
|
---|
59 | {
|
---|
60 | TRACE("width = 0x%08x height = 0x%08x\n", entry->bWidth, entry->bHeight);
|
---|
61 | TRACE("colors = 0x%08x planes = 0x%08x\n", entry->bColorCount, entry->wPlanes);
|
---|
62 | TRACE("bitcount = 0x%08x bytesinres = 0x%08lx offset = 0x%08lx\n",
|
---|
63 | entry->wBitCount, entry->dwBytesInRes, entry->dwImageOffset);
|
---|
64 | }
|
---|
65 | static void dumpIcoDir ( LPicoICONDIR entry )
|
---|
66 | {
|
---|
67 | TRACE("type = 0x%08x count = 0x%08x\n", entry->idType, entry->idCount);
|
---|
68 | }
|
---|
69 | #endif
|
---|
70 |
|
---|
71 |
|
---|
72 | HDPA sic_hdpa = 0;
|
---|
73 | static CRITICAL_SECTION SHELL32_SicCS;
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 | /*************************************************************************
|
---|
78 | * SHELL_GetResourceTable
|
---|
79 | */
|
---|
80 | static DWORD SHELL_GetResourceTable(HFILE hFile, LPBYTE *retptr)
|
---|
81 | { IMAGE_DOS_HEADER mz_header;
|
---|
82 | char magic[4];
|
---|
83 | int size;
|
---|
84 |
|
---|
85 | TRACE("0x%08x %p\n", hFile, retptr);
|
---|
86 |
|
---|
87 | *retptr = NULL;
|
---|
88 | _llseek( hFile, 0, SEEK_SET );
|
---|
89 | if ((_lread(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) || (mz_header.e_magic != IMAGE_DOS_SIGNATURE))
|
---|
90 | { if (mz_header.e_cblp == 1) /* .ICO file ? */
|
---|
91 | { *retptr = (LPBYTE)-1; /* ICONHEADER.idType, must be 1 */
|
---|
92 | return 1;
|
---|
93 | }
|
---|
94 | else
|
---|
95 | return 0; /* failed */
|
---|
96 | }
|
---|
97 | _llseek( hFile, mz_header.e_lfanew, SEEK_SET );
|
---|
98 |
|
---|
99 | if (_lread( hFile, magic, sizeof(magic) ) != sizeof(magic))
|
---|
100 | return 0;
|
---|
101 |
|
---|
102 | _llseek( hFile, mz_header.e_lfanew, SEEK_SET);
|
---|
103 |
|
---|
104 | if (*(DWORD*)magic == IMAGE_NT_SIGNATURE)
|
---|
105 | return IMAGE_NT_SIGNATURE;
|
---|
106 |
|
---|
107 | if (*(WORD*)magic == IMAGE_OS2_SIGNATURE)
|
---|
108 | { IMAGE_OS2_HEADER ne_header;
|
---|
109 | LPBYTE pTypeInfo = (LPBYTE)-1;
|
---|
110 |
|
---|
111 | if (_lread(hFile,&ne_header,sizeof(ne_header))!=sizeof(ne_header))
|
---|
112 | return 0;
|
---|
113 |
|
---|
114 | if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE)
|
---|
115 | return 0;
|
---|
116 |
|
---|
117 | size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
|
---|
118 |
|
---|
119 | //@@@PH no NE support
|
---|
120 | #if 0
|
---|
121 | if( size > sizeof(NE_TYPEINFO) )
|
---|
122 | { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
|
---|
123 | if( pTypeInfo )
|
---|
124 | { _llseek(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
|
---|
125 | if( _lread( hFile, (char*)pTypeInfo, size) != size )
|
---|
126 | { HeapFree( GetProcessHeap(), 0, pTypeInfo);
|
---|
127 | pTypeInfo = NULL;
|
---|
128 | }
|
---|
129 | }
|
---|
130 | }
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | *retptr = pTypeInfo;
|
---|
134 | return IMAGE_OS2_SIGNATURE;
|
---|
135 | }
|
---|
136 | return 0; /* failed */
|
---|
137 | }
|
---|
138 | /*************************************************************************
|
---|
139 | * SHELL_LoadResource
|
---|
140 | */
|
---|
141 | //@@@PH no NE support
|
---|
142 | #if 0
|
---|
143 | static BYTE * SHELL_LoadResource( HFILE hFile, NE_NAMEINFO* pNInfo, WORD sizeShift, ULONG *uSize)
|
---|
144 | { BYTE* ptr;
|
---|
145 |
|
---|
146 | TRACE("0x%08x %p 0x%08x\n", hFile, pNInfo, sizeShift);
|
---|
147 |
|
---|
148 | *uSize = (DWORD)pNInfo->length << sizeShift;
|
---|
149 | if( (ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize) ))
|
---|
150 | { _llseek( hFile, (DWORD)pNInfo->offset << sizeShift, SEEK_SET);
|
---|
151 | _lread( hFile, (char*)ptr, pNInfo->length << sizeShift);
|
---|
152 | return ptr;
|
---|
153 | }
|
---|
154 | return 0;
|
---|
155 | }
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | /*************************************************************************
|
---|
159 | * ICO_LoadIcon
|
---|
160 | */
|
---|
161 | static BYTE * ICO_LoadIcon( HFILE hFile, LPicoICONDIRENTRY lpiIDE, ULONG *uSize)
|
---|
162 | { BYTE* ptr;
|
---|
163 |
|
---|
164 | TRACE("0x%08x %p\n", hFile, lpiIDE);
|
---|
165 |
|
---|
166 | *uSize = lpiIDE->dwBytesInRes;
|
---|
167 | if( (ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize)) )
|
---|
168 | { _llseek( hFile, lpiIDE->dwImageOffset, SEEK_SET);
|
---|
169 | _lread( hFile, (char*)ptr, lpiIDE->dwBytesInRes);
|
---|
170 | return ptr;
|
---|
171 | }
|
---|
172 |
|
---|
173 | return 0;
|
---|
174 | }
|
---|
175 |
|
---|
176 | /*************************************************************************
|
---|
177 | * ICO_GetIconDirectory
|
---|
178 | *
|
---|
179 | * Reads .ico file and build phony ICONDIR struct
|
---|
180 | * see http://www.microsoft.com/win32dev/ui/icons.htm
|
---|
181 | */
|
---|
182 | #define HEADER_SIZE (sizeof(CURSORICONDIR) - sizeof (CURSORICONDIRENTRY))
|
---|
183 | #define HEADER_SIZE_FILE (sizeof(icoICONDIR) - sizeof (icoICONDIRENTRY))
|
---|
184 |
|
---|
185 | static BYTE * ICO_GetIconDirectory( HFILE hFile, LPicoICONDIR* lplpiID, ULONG *uSize )
|
---|
186 | { CURSORICONDIR lpcid; /* icon resource in resource-dir format */
|
---|
187 | LPicoICONDIR lpiID; /* icon resource in file format */
|
---|
188 | int i;
|
---|
189 |
|
---|
190 | TRACE("0x%08x %p\n", hFile, lplpiID);
|
---|
191 |
|
---|
192 | _llseek( hFile, 0, SEEK_SET );
|
---|
193 | if( _lread(hFile,(char*)&lpcid, HEADER_SIZE_FILE) != HEADER_SIZE_FILE )
|
---|
194 | return 0;
|
---|
195 |
|
---|
196 | if( lpcid.idReserved || (lpcid.idType != 1) || (!lpcid.idCount) )
|
---|
197 | return 0;
|
---|
198 |
|
---|
199 | i = lpcid.idCount * sizeof(icoICONDIRENTRY);
|
---|
200 | lpiID = (LPicoICONDIR)HeapAlloc( GetProcessHeap(), 0, HEADER_SIZE_FILE + i);
|
---|
201 |
|
---|
202 | if( _lread(hFile,(char*)lpiID->idEntries,i) == i )
|
---|
203 | { CURSORICONDIR * lpID; /* icon resource in resource format */
|
---|
204 | *uSize = lpcid.idCount * sizeof(CURSORICONDIRENTRY) + HEADER_SIZE;
|
---|
205 | if( (lpID = (CURSORICONDIR*)HeapAlloc(GetProcessHeap(),0, *uSize) ))
|
---|
206 | {
|
---|
207 | /* copy the header */
|
---|
208 | lpID->idReserved = lpiID->idReserved = 0;
|
---|
209 | lpID->idType = lpiID->idType = 1;
|
---|
210 | lpID->idCount = lpiID->idCount = lpcid.idCount;
|
---|
211 |
|
---|
212 | /* copy the entrys */
|
---|
213 | for( i=0; i < lpiID->idCount; i++ )
|
---|
214 | { memcpy((void*)&(lpID->idEntries[i]),(void*)&(lpiID->idEntries[i]), sizeof(CURSORICONDIRENTRY) - 2);
|
---|
215 | lpID->idEntries[i].wResId = i;
|
---|
216 | }
|
---|
217 |
|
---|
218 | *lplpiID = lpiID;
|
---|
219 | return (BYTE *)lpID;
|
---|
220 | }
|
---|
221 | }
|
---|
222 | /* fail */
|
---|
223 |
|
---|
224 | HeapFree( GetProcessHeap(), 0, lpiID);
|
---|
225 | return 0;
|
---|
226 | }
|
---|
227 |
|
---|
228 | /*************************************************************************
|
---|
229 | * InternalExtractIcon [SHELL.39]
|
---|
230 | *
|
---|
231 | * This abortion is called directly by Progman
|
---|
232 | * fixme: the icon section is broken (don't have a handle for
|
---|
233 | * ICO_GetIconDirectory....)
|
---|
234 | *
|
---|
235 | */
|
---|
236 | #define ICO_INVALID_FILE 1
|
---|
237 | #define ICO_NO_ICONS 0
|
---|
238 |
|
---|
239 | HGLOBAL WINAPI ICO_ExtractIconEx(LPCSTR lpszExeFileName, HICON * RetPtr, UINT nIconIndex, UINT n, UINT cxDesired, UINT cyDesired )
|
---|
240 | {
|
---|
241 | dprintf (("SHELL32: ICO_ExtractIconEx not implemented.\n"));
|
---|
242 | return 0;
|
---|
243 | }
|
---|
244 |
|
---|
245 | // @@@PH turned off
|
---|
246 | #if 0
|
---|
247 | { HGLOBAL hRet = ICO_NO_ICONS;
|
---|
248 | LPBYTE pData;
|
---|
249 | OFSTRUCT ofs;
|
---|
250 | DWORD sig;
|
---|
251 | HFILE hFile = OpenFile( lpszExeFileName, &ofs, OF_READ );
|
---|
252 | UINT16 iconDirCount = 0,iconCount = 0;
|
---|
253 | LPBYTE peimage;
|
---|
254 | HANDLE fmapping;
|
---|
255 | ULONG uSize;
|
---|
256 |
|
---|
257 | TRACE("(file %s,start %d,extract %d\n", lpszExeFileName, nIconIndex, n);
|
---|
258 |
|
---|
259 | if( hFile == HFILE_ERROR || !n )
|
---|
260 | return ICO_INVALID_FILE;
|
---|
261 |
|
---|
262 | sig = SHELL_GetResourceTable(hFile,&pData);
|
---|
263 |
|
---|
264 | //@@@PH no NE support
|
---|
265 | #if 0
|
---|
266 | /* ico file */
|
---|
267 | if( sig==IMAGE_OS2_SIGNATURE || sig==1 ) /* .ICO file */
|
---|
268 | { BYTE *pCIDir = 0;
|
---|
269 | NE_TYPEINFO *pTInfo = (NE_TYPEINFO*)(pData + 2);
|
---|
270 | NE_NAMEINFO *pIconStorage = NULL;
|
---|
271 | NE_NAMEINFO *pIconDir = NULL;
|
---|
272 | LPicoICONDIR lpiID = NULL;
|
---|
273 |
|
---|
274 | TRACE("-- OS2/icon Signature (0x%08lx)\n", sig);
|
---|
275 |
|
---|
276 | if( pData == (BYTE*)-1 )
|
---|
277 | { pCIDir = ICO_GetIconDirectory(hFile, &lpiID, &uSize); /* check for .ICO file */
|
---|
278 | if( pCIDir )
|
---|
279 | { iconDirCount = 1; iconCount = lpiID->idCount;
|
---|
280 | TRACE("-- icon found %p 0x%08lx 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
|
---|
281 | }
|
---|
282 | }
|
---|
283 | else while( pTInfo->type_id && !(pIconStorage && pIconDir) )
|
---|
284 | { if( pTInfo->type_id == NE_RSCTYPE_GROUP_ICON ) /* find icon directory and icon repository */
|
---|
285 | { iconDirCount = pTInfo->count;
|
---|
286 | pIconDir = ((NE_NAMEINFO*)(pTInfo + 1));
|
---|
287 | TRACE("\tfound directory - %i icon families\n", iconDirCount);
|
---|
288 | }
|
---|
289 | if( pTInfo->type_id == NE_RSCTYPE_ICON )
|
---|
290 | { iconCount = pTInfo->count;
|
---|
291 | pIconStorage = ((NE_NAMEINFO*)(pTInfo + 1));
|
---|
292 | TRACE("\ttotal icons - %i\n", iconCount);
|
---|
293 | }
|
---|
294 | pTInfo = (NE_TYPEINFO *)((char*)(pTInfo+1)+pTInfo->count*sizeof(NE_NAMEINFO));
|
---|
295 | }
|
---|
296 |
|
---|
297 | if( (pIconStorage && pIconDir) || lpiID ) /* load resources and create icons */
|
---|
298 | { if( nIconIndex == (UINT16)-1 )
|
---|
299 | { RetPtr[0] = iconDirCount;
|
---|
300 | }
|
---|
301 | else if( nIconIndex < iconDirCount )
|
---|
302 | { UINT16 i, icon;
|
---|
303 | if( n > iconDirCount - nIconIndex )
|
---|
304 | n = iconDirCount - nIconIndex;
|
---|
305 |
|
---|
306 | for( i = nIconIndex; i < nIconIndex + n; i++ )
|
---|
307 | { /* .ICO files have only one icon directory */
|
---|
308 |
|
---|
309 | if( lpiID == NULL ) /* *.ico */
|
---|
310 | pCIDir = SHELL_LoadResource( hFile, pIconDir + i, *(WORD*)pData, &uSize );
|
---|
311 | RetPtr[i-nIconIndex] = pLookupIconIdFromDirectoryEx( pCIDir, TRUE, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0);
|
---|
312 | HeapFree(GetProcessHeap(), 0, pCIDir);
|
---|
313 | }
|
---|
314 |
|
---|
315 | for( icon = nIconIndex; icon < nIconIndex + n; icon++ )
|
---|
316 | { pCIDir = NULL;
|
---|
317 | if( lpiID )
|
---|
318 | { pCIDir = ICO_LoadIcon( hFile, lpiID->idEntries + RetPtr[icon-nIconIndex], &uSize);
|
---|
319 | }
|
---|
320 | else
|
---|
321 | { for( i = 0; i < iconCount; i++ )
|
---|
322 | { if( pIconStorage[i].id == (RetPtr[icon-nIconIndex] | 0x8000) )
|
---|
323 | { pCIDir = SHELL_LoadResource( hFile, pIconStorage + i,*(WORD*)pData, &uSize );
|
---|
324 | }
|
---|
325 | }
|
---|
326 | }
|
---|
327 | if( pCIDir )
|
---|
328 | { RetPtr[icon-nIconIndex] = (HICON) pCreateIconFromResourceEx(pCIDir,uSize,TRUE,0x00030000, cxDesired, cyDesired, LR_DEFAULTCOLOR);
|
---|
329 | }
|
---|
330 | else
|
---|
331 | { RetPtr[icon-nIconIndex] = 0;
|
---|
332 | }
|
---|
333 | }
|
---|
334 | }
|
---|
335 | }
|
---|
336 | if( lpiID )
|
---|
337 | HeapFree( GetProcessHeap(), 0, lpiID);
|
---|
338 | else
|
---|
339 | HeapFree( GetProcessHeap(), 0, pData);
|
---|
340 | }
|
---|
341 | /* end ico file */
|
---|
342 | #endif
|
---|
343 |
|
---|
344 | /* exe/dll */
|
---|
345 | if( sig == IMAGE_NT_SIGNATURE)
|
---|
346 | { LPBYTE idata,igdata;
|
---|
347 | PIMAGE_DOS_HEADER dheader;
|
---|
348 | PIMAGE_NT_HEADERS pe_header;
|
---|
349 | PIMAGE_SECTION_HEADER pe_sections;
|
---|
350 | PIMAGE_RESOURCE_DIRECTORY rootresdir,iconresdir,icongroupresdir;
|
---|
351 | PIMAGE_RESOURCE_DATA_ENTRY idataent,igdataent;
|
---|
352 | PIMAGE_RESOURCE_DIRECTORY_ENTRY xresent;
|
---|
353 | int i,j;
|
---|
354 |
|
---|
355 | if ( !(fmapping = CreateFileMappingA(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL)))
|
---|
356 | { WARN("failed to create filemap.\n"); /* FIXME, INVALID_HANDLE_VALUE? */
|
---|
357 | hRet = ICO_INVALID_FILE;
|
---|
358 | goto end_2; /* failure */
|
---|
359 | }
|
---|
360 |
|
---|
361 | if ( !(peimage = (BYTE*)MapViewOfFile(fmapping,FILE_MAP_READ,0,0,0)))
|
---|
362 | { WARN("failed to mmap filemap.\n");
|
---|
363 | hRet = ICO_INVALID_FILE;
|
---|
364 | goto end_2; /* failure */
|
---|
365 | }
|
---|
366 |
|
---|
367 | dheader = (PIMAGE_DOS_HEADER)peimage;
|
---|
368 | pe_header = (PIMAGE_NT_HEADERS)(peimage+dheader->e_lfanew); /* it is a pe header, SHELL_GetResourceTable checked that */
|
---|
369 | pe_sections = (PIMAGE_SECTION_HEADER)(((char*)pe_header)+sizeof(*pe_header)); /* probably makes problems with short PE headers...*/
|
---|
370 | rootresdir = NULL;
|
---|
371 |
|
---|
372 | for (i=0;i<pe_header->FileHeader.NumberOfSections;i++)
|
---|
373 | { if (pe_sections[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
|
---|
374 | continue;
|
---|
375 | /* FIXME: doesn't work when the resources are not in a seperate section */
|
---|
376 | if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress)
|
---|
377 | { rootresdir = (PIMAGE_RESOURCE_DIRECTORY)((char*)peimage+pe_sections[i].PointerToRawData);
|
---|
378 | break;
|
---|
379 | }
|
---|
380 | }
|
---|
381 |
|
---|
382 | if (!rootresdir)
|
---|
383 | { WARN("haven't found section for resource directory.\n");
|
---|
384 | goto end_4; /* failure */
|
---|
385 | }
|
---|
386 | /* search the group icon dir*/
|
---|
387 | if (!(icongroupresdir = GetResDirEntryW(rootresdir,RT_GROUP_ICONW, (DWORD)rootresdir,FALSE)))
|
---|
388 | { WARN("No Icongroupresourcedirectory!\n");
|
---|
389 | goto end_4; /* failure */
|
---|
390 | }
|
---|
391 | iconDirCount = icongroupresdir->NumberOfNamedEntries+icongroupresdir->NumberOfIdEntries;
|
---|
392 |
|
---|
393 | /* number of icons requested */
|
---|
394 | if( nIconIndex == -1 )
|
---|
395 | { hRet = iconDirCount;
|
---|
396 | goto end_3; /* success */
|
---|
397 | }
|
---|
398 |
|
---|
399 | if (nIconIndex >= iconDirCount)
|
---|
400 | { WARN("nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
|
---|
401 | goto end_4; /* failure */
|
---|
402 | }
|
---|
403 |
|
---|
404 | xresent = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(icongroupresdir+1); /* caller just wanted the number of entries */
|
---|
405 |
|
---|
406 | if( n > iconDirCount - nIconIndex ) /* assure we don't get too much ... */
|
---|
407 | { n = iconDirCount - nIconIndex;
|
---|
408 | }
|
---|
409 |
|
---|
410 | xresent = xresent+nIconIndex; /* starting from specified index ... */
|
---|
411 |
|
---|
412 | for (i=0;i<n;i++,xresent++)
|
---|
413 | { PIMAGE_RESOURCE_DIRECTORY resdir;
|
---|
414 |
|
---|
415 | /* go down this resource entry, name */
|
---|
416 | resdir = (PIMAGE_RESOURCE_DIRECTORY)((DWORD)rootresdir+(xresent->u2.s.OffsetToDirectory));
|
---|
417 |
|
---|
418 | /* default language (0) */
|
---|
419 | resdir = GetResDirEntryW(resdir,(LPWSTR)0,(DWORD)rootresdir,TRUE);
|
---|
420 | igdataent = (PIMAGE_RESOURCE_DATA_ENTRY)resdir;
|
---|
421 |
|
---|
422 | /* lookup address in mapped image for virtual address */
|
---|
423 | igdata = NULL;
|
---|
424 |
|
---|
425 | for (j=0;j<pe_header->FileHeader.NumberOfSections;j++)
|
---|
426 | { if (igdataent->OffsetToData < pe_sections[j].VirtualAddress)
|
---|
427 | continue;
|
---|
428 | if (igdataent->OffsetToData+igdataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
|
---|
429 | continue;
|
---|
430 | igdata = peimage+(igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
|
---|
431 | }
|
---|
432 |
|
---|
433 | if (!igdata)
|
---|
434 | { WARN("no matching real address for icongroup!\n");
|
---|
435 | goto end_4; /* failure */
|
---|
436 | }
|
---|
437 | RetPtr[i] = (HICON)pLookupIconIdFromDirectoryEx(igdata, TRUE, cxDesired, cyDesired, LR_DEFAULTCOLOR);
|
---|
438 | }
|
---|
439 |
|
---|
440 | if (!(iconresdir=GetResDirEntryW(rootresdir,RT_ICONW,(DWORD)rootresdir,FALSE)))
|
---|
441 | { WARN("No Iconresourcedirectory!\n");
|
---|
442 | goto end_4; /* failure */
|
---|
443 | }
|
---|
444 |
|
---|
445 | for (i=0;i<n;i++)
|
---|
446 | { PIMAGE_RESOURCE_DIRECTORY xresdir;
|
---|
447 | xresdir = GetResDirEntryW(iconresdir,(LPWSTR)(DWORD)RetPtr[i],(DWORD)rootresdir,FALSE);
|
---|
448 | xresdir = GetResDirEntryW(xresdir,(LPWSTR)0,(DWORD)rootresdir,TRUE);
|
---|
449 | idataent = (PIMAGE_RESOURCE_DATA_ENTRY)xresdir;
|
---|
450 | idata = NULL;
|
---|
451 |
|
---|
452 | /* map virtual to address in image */
|
---|
453 | for (j=0;j<pe_header->FileHeader.NumberOfSections;j++)
|
---|
454 | { if (idataent->OffsetToData < pe_sections[j].VirtualAddress)
|
---|
455 | continue;
|
---|
456 | if (idataent->OffsetToData+idataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
|
---|
457 | continue;
|
---|
458 | idata = peimage+(idataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
|
---|
459 | }
|
---|
460 | if (!idata)
|
---|
461 | { WARN("no matching real address found for icondata!\n");
|
---|
462 | RetPtr[i]=0;
|
---|
463 | continue;
|
---|
464 | }
|
---|
465 | RetPtr[i] = (HICON) pCreateIconFromResourceEx(idata,idataent->Size,TRUE,0x00030000, cxDesired, cyDesired, LR_DEFAULTCOLOR);
|
---|
466 | }
|
---|
467 | hRet = RetPtr[0]; /* return first icon */
|
---|
468 | goto end_3; /* sucess */
|
---|
469 | }
|
---|
470 | hRet = ICO_INVALID_FILE;
|
---|
471 | goto end_1; /* unknown filetype */
|
---|
472 |
|
---|
473 | /* cleaning up (try & catch would be nicer:-) ) */
|
---|
474 | end_4: hRet = 0; /* failure */
|
---|
475 | end_3: UnmapViewOfFile(peimage); /* success */
|
---|
476 | end_2: CloseHandle(fmapping);
|
---|
477 | end_1: _lclose( hFile);
|
---|
478 | return hRet;
|
---|
479 | }
|
---|
480 | #endif
|
---|
481 |
|
---|
482 | /********************** THE ICON CACHE ********************************/
|
---|
483 |
|
---|
484 | #define INVALID_INDEX -1
|
---|
485 |
|
---|
486 | typedef struct
|
---|
487 | { LPCSTR sSourceFile; /* file (not path!) containing the icon */
|
---|
488 | DWORD dwSourceIndex; /* index within the file, if it is a resoure ID it will be negated */
|
---|
489 | DWORD dwListIndex; /* index within the iconlist */
|
---|
490 | DWORD dwFlags; /* GIL_* flags */
|
---|
491 | DWORD dwAccessTime;
|
---|
492 | } SIC_ENTRY, * LPSIC_ENTRY;
|
---|
493 |
|
---|
494 | /*****************************************************************************
|
---|
495 | * SIC_CompareEntrys [called by comctl32.dll]
|
---|
496 | *
|
---|
497 | * NOTES
|
---|
498 | * Callback for DPA_Search
|
---|
499 | */
|
---|
500 | INT CALLBACK SIC_CompareEntrys( LPVOID p1, LPVOID p2, LPARAM lparam)
|
---|
501 | { TRACE("%p %p\n", p1, p2);
|
---|
502 |
|
---|
503 | if (((LPSIC_ENTRY)p1)->dwSourceIndex != ((LPSIC_ENTRY)p2)->dwSourceIndex) /* first the faster one*/
|
---|
504 | return 1;
|
---|
505 |
|
---|
506 | if (strcmp(((LPSIC_ENTRY)p1)->sSourceFile,((LPSIC_ENTRY)p2)->sSourceFile))
|
---|
507 | return 1;
|
---|
508 |
|
---|
509 | return 0;
|
---|
510 | }
|
---|
511 | /*****************************************************************************
|
---|
512 | * SIC_IconAppend [internal]
|
---|
513 | *
|
---|
514 | * NOTES
|
---|
515 | * appends a icon pair to the end of the cache
|
---|
516 | */
|
---|
517 | static INT SIC_IconAppend (LPCSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon)
|
---|
518 | { LPSIC_ENTRY lpsice;
|
---|
519 | INT ret, index, index1;
|
---|
520 |
|
---|
521 | TRACE("%s %i %x %x\n", sSourceFile, dwSourceIndex, hSmallIcon ,hBigIcon);
|
---|
522 |
|
---|
523 | lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY));
|
---|
524 |
|
---|
525 | lpsice->sSourceFile = HEAP_strdupA (GetProcessHeap(), 0, PathFindFilenameA(sSourceFile));
|
---|
526 | lpsice->dwSourceIndex = dwSourceIndex;
|
---|
527 |
|
---|
528 | EnterCriticalSection(&SHELL32_SicCS);
|
---|
529 |
|
---|
530 | index = pDPA_InsertPtr(sic_hdpa, 0x7fff, lpsice);
|
---|
531 | if ( INVALID_INDEX == index )
|
---|
532 | {
|
---|
533 | SHFree(lpsice);
|
---|
534 | ret = INVALID_INDEX;
|
---|
535 | }
|
---|
536 | else
|
---|
537 | {
|
---|
538 | index = pImageList_AddIcon (ShellSmallIconList, hSmallIcon);
|
---|
539 | index1= pImageList_AddIcon (ShellBigIconList, hBigIcon);
|
---|
540 |
|
---|
541 | if (index!=index1)
|
---|
542 | {
|
---|
543 | FIXME("iconlists out of sync 0x%x 0x%x\n", index, index1);
|
---|
544 | }
|
---|
545 | lpsice->dwListIndex = index;
|
---|
546 | ret = lpsice->dwListIndex;
|
---|
547 | }
|
---|
548 |
|
---|
549 | LeaveCriticalSection(&SHELL32_SicCS);
|
---|
550 | return ret;
|
---|
551 | }
|
---|
552 | /****************************************************************************
|
---|
553 | * SIC_LoadIcon [internal]
|
---|
554 | *
|
---|
555 | * NOTES
|
---|
556 | * gets small/big icon by number from a file
|
---|
557 | */
|
---|
558 | static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex)
|
---|
559 | { HICON hiconLarge=0;
|
---|
560 | HICON hiconSmall=0;
|
---|
561 |
|
---|
562 | ICO_ExtractIconEx(sSourceFile, &hiconLarge, dwSourceIndex, 1, 32, 32 );
|
---|
563 | ICO_ExtractIconEx(sSourceFile, &hiconSmall, dwSourceIndex, 1, 16, 16 );
|
---|
564 |
|
---|
565 |
|
---|
566 | if ( !hiconLarge || !hiconSmall)
|
---|
567 | {
|
---|
568 | WARN("failure loading icon %i from %s (%x %x)\n", dwSourceIndex, sSourceFile, hiconLarge, hiconSmall);
|
---|
569 | return -1;
|
---|
570 | }
|
---|
571 | return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge);
|
---|
572 | }
|
---|
573 | /*****************************************************************************
|
---|
574 | * SIC_GetIconIndex [internal]
|
---|
575 | *
|
---|
576 | * Parameters
|
---|
577 | * sSourceFile [IN] filename of file containing the icon
|
---|
578 | * index [IN] index/resID (negated) in this file
|
---|
579 | *
|
---|
580 | * NOTES
|
---|
581 | * look in the cache for a proper icon. if not available the icon is taken
|
---|
582 | * from the file and cached
|
---|
583 | */
|
---|
584 | INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex )
|
---|
585 | { SIC_ENTRY sice;
|
---|
586 | INT ret, index = INVALID_INDEX;
|
---|
587 |
|
---|
588 | TRACE("%s %i\n", sSourceFile, dwSourceIndex);
|
---|
589 |
|
---|
590 | sice.sSourceFile = PathFindFilenameA(sSourceFile);
|
---|
591 | sice.dwSourceIndex = dwSourceIndex;
|
---|
592 |
|
---|
593 | EnterCriticalSection(&SHELL32_SicCS);
|
---|
594 |
|
---|
595 | if (NULL != pDPA_GetPtr (sic_hdpa, 0))
|
---|
596 | {
|
---|
597 | index = pDPA_Search (sic_hdpa, &sice, -1L, (PFNDPACOMPARE)SIC_CompareEntrys, 0, 0);
|
---|
598 | }
|
---|
599 |
|
---|
600 | if ( INVALID_INDEX == index )
|
---|
601 | {
|
---|
602 | ret = SIC_LoadIcon (sSourceFile, dwSourceIndex);
|
---|
603 | }
|
---|
604 | else
|
---|
605 | {
|
---|
606 | TRACE("-- found\n");
|
---|
607 | ret = ((LPSIC_ENTRY)pDPA_GetPtr(sic_hdpa, index))->dwListIndex;
|
---|
608 | }
|
---|
609 |
|
---|
610 | LeaveCriticalSection(&SHELL32_SicCS);
|
---|
611 | return ret;
|
---|
612 | }
|
---|
613 | /****************************************************************************
|
---|
614 | * SIC_LoadIcon [internal]
|
---|
615 | *
|
---|
616 | * NOTES
|
---|
617 | * retrives the specified icon from the iconcache. if not found try's to load the icon
|
---|
618 | */
|
---|
619 | static HICON WINE_UNUSED SIC_GetIcon (LPCSTR sSourceFile, INT dwSourceIndex, BOOL bSmallIcon )
|
---|
620 | { INT index;
|
---|
621 |
|
---|
622 | TRACE("%s %i\n", sSourceFile, dwSourceIndex);
|
---|
623 |
|
---|
624 | index = SIC_GetIconIndex(sSourceFile, dwSourceIndex);
|
---|
625 |
|
---|
626 | if (INVALID_INDEX == index)
|
---|
627 | {
|
---|
628 | return INVALID_INDEX;
|
---|
629 | }
|
---|
630 |
|
---|
631 | if (bSmallIcon)
|
---|
632 | return pImageList_GetIcon(ShellSmallIconList, index, ILD_NORMAL);
|
---|
633 | return pImageList_GetIcon(ShellBigIconList, index, ILD_NORMAL);
|
---|
634 |
|
---|
635 | }
|
---|
636 | /*****************************************************************************
|
---|
637 | * SIC_Initialize [internal]
|
---|
638 | *
|
---|
639 | * NOTES
|
---|
640 | * hack to load the resources from the shell32.dll under a different dll name
|
---|
641 | * will be removed when the resource-compiler is ready
|
---|
642 | */
|
---|
643 | BOOL SIC_Initialize(void)
|
---|
644 | {
|
---|
645 | HICON hSm, hLg;
|
---|
646 | UINT index;
|
---|
647 |
|
---|
648 | TRACE("\n");
|
---|
649 |
|
---|
650 | if (sic_hdpa) /* already initialized?*/
|
---|
651 | return TRUE;
|
---|
652 |
|
---|
653 | InitializeCriticalSection(&SHELL32_SicCS);
|
---|
654 |
|
---|
655 | sic_hdpa = pDPA_Create(16);
|
---|
656 |
|
---|
657 | if (!sic_hdpa)
|
---|
658 | {
|
---|
659 | return(FALSE);
|
---|
660 | }
|
---|
661 |
|
---|
662 | ShellSmallIconList = pImageList_Create(16,16,ILC_COLORDDB | ILC_MASK,0,0x20);
|
---|
663 | ShellBigIconList = pImageList_Create(32,32,ILC_COLORDDB | ILC_MASK,0,0x20);
|
---|
664 |
|
---|
665 | pImageList_SetBkColor(ShellSmallIconList, GetSysColor(COLOR_WINDOW));
|
---|
666 | pImageList_SetBkColor(ShellBigIconList, GetSysColor(COLOR_WINDOW));
|
---|
667 |
|
---|
668 | for (index=1; index<39; index++)
|
---|
669 | {
|
---|
670 | hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(index), IMAGE_ICON, 16, 16,LR_SHARED);
|
---|
671 | hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(index), IMAGE_ICON, 32, 32,LR_SHARED);
|
---|
672 |
|
---|
673 | if(!hSm)
|
---|
674 | {
|
---|
675 | hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 16, 16,LR_SHARED);
|
---|
676 | hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 32, 32,LR_SHARED);
|
---|
677 | }
|
---|
678 | SIC_IconAppend ("shell32.dll", index, hSm, hLg);
|
---|
679 | }
|
---|
680 |
|
---|
681 | TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
|
---|
682 |
|
---|
683 | return TRUE;
|
---|
684 | }
|
---|
685 | /*************************************************************************
|
---|
686 | * SIC_Destroy
|
---|
687 | *
|
---|
688 | * frees the cache
|
---|
689 | */
|
---|
690 | void SIC_Destroy(void)
|
---|
691 | {
|
---|
692 | LPSIC_ENTRY lpsice;
|
---|
693 | int i;
|
---|
694 |
|
---|
695 | TRACE("\n");
|
---|
696 |
|
---|
697 | EnterCriticalSection(&SHELL32_SicCS);
|
---|
698 |
|
---|
699 | if (sic_hdpa && NULL != pDPA_GetPtr (sic_hdpa, 0))
|
---|
700 | {
|
---|
701 | for (i=0; i < pDPA_GetPtrCount(sic_hdpa); ++i)
|
---|
702 | {
|
---|
703 | lpsice = (LPSIC_ENTRY)pDPA_GetPtr(sic_hdpa, i);
|
---|
704 | SHFree(lpsice);
|
---|
705 | }
|
---|
706 | pDPA_Destroy(sic_hdpa);
|
---|
707 | }
|
---|
708 |
|
---|
709 | sic_hdpa = NULL;
|
---|
710 |
|
---|
711 | LeaveCriticalSection(&SHELL32_SicCS);
|
---|
712 | }
|
---|
713 | /*************************************************************************
|
---|
714 | * Shell_GetImageList [SHELL32.71]
|
---|
715 | *
|
---|
716 | * PARAMETERS
|
---|
717 | * imglist[1|2] [OUT] pointer which recive imagelist handles
|
---|
718 | *
|
---|
719 | */
|
---|
720 | BOOL WINAPI Shell_GetImageList(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList)
|
---|
721 | { TRACE("(%p,%p)\n",lpBigList,lpSmallList);
|
---|
722 | if (lpBigList)
|
---|
723 | { *lpBigList = ShellBigIconList;
|
---|
724 | }
|
---|
725 | if (lpSmallList)
|
---|
726 | { *lpSmallList = ShellSmallIconList;
|
---|
727 | }
|
---|
728 |
|
---|
729 | return TRUE;
|
---|
730 | }
|
---|
731 | /*************************************************************************
|
---|
732 | * PidlToSicIndex [INTERNAL]
|
---|
733 | *
|
---|
734 | * PARAMETERS
|
---|
735 | * sh [IN] IShellFolder
|
---|
736 | * pidl [IN]
|
---|
737 | * bBigIcon [IN]
|
---|
738 | * pIndex [OUT] index within the SIC
|
---|
739 | *
|
---|
740 | */
|
---|
741 | BOOL PidlToSicIndex (IShellFolder * sh, LPITEMIDLIST pidl, BOOL bBigIcon, UINT * pIndex)
|
---|
742 | {
|
---|
743 | IExtractIcon *ei;
|
---|
744 | char szIconFile[MAX_PATH]; /* file containing the icon */
|
---|
745 | INT iSourceIndex; /* index or resID(negated) in this file */
|
---|
746 | BOOL ret = FALSE;
|
---|
747 | UINT dwFlags = 0;
|
---|
748 |
|
---|
749 | TRACE("sf=%p pidl=%p\n", sh, pidl);
|
---|
750 |
|
---|
751 | if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconA, 0, (void **)&ei)))
|
---|
752 | {
|
---|
753 | if (NOERROR==IExtractIconA_GetIconLocation(ei, 0, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags))
|
---|
754 | { *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex);
|
---|
755 | ret = TRUE;
|
---|
756 | }
|
---|
757 | IExtractIconA_Release(ei);
|
---|
758 | }
|
---|
759 |
|
---|
760 | if (INVALID_INDEX == *pIndex) /* default icon when failed */
|
---|
761 | *pIndex = 1;
|
---|
762 |
|
---|
763 | return ret;
|
---|
764 |
|
---|
765 | }
|
---|
766 |
|
---|
767 | /*************************************************************************
|
---|
768 | * SHMapPIDLToSystemImageListIndex [SHELL32.77]
|
---|
769 | *
|
---|
770 | * PARAMETERS
|
---|
771 | * sh [IN] pointer to an instance of IShellFolder
|
---|
772 | * pidl [IN]
|
---|
773 | * pIndex [OUT][OPTIONAL] SIC index for big icon
|
---|
774 | *
|
---|
775 | */
|
---|
776 | UINT WINAPI SHMapPIDLToSystemImageListIndex(LPSHELLFOLDER sh, LPITEMIDLIST pidl, UINT * pIndex)
|
---|
777 | {
|
---|
778 | UINT Index;
|
---|
779 |
|
---|
780 | TRACE("(SF=%p,pidl=%p,%p)\n",sh,pidl,pIndex);
|
---|
781 | pdump(pidl);
|
---|
782 |
|
---|
783 | if (pIndex)
|
---|
784 | PidlToSicIndex ( sh, pidl, 1, pIndex);
|
---|
785 | PidlToSicIndex ( sh, pidl, 0, &Index);
|
---|
786 | return Index;
|
---|
787 | }
|
---|
788 |
|
---|
789 | /*************************************************************************
|
---|
790 | * Shell_GetCachedImageIndex [SHELL32.72]
|
---|
791 | *
|
---|
792 | */
|
---|
793 | INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc)
|
---|
794 | {
|
---|
795 | WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc);
|
---|
796 | return SIC_GetIconIndex(szPath, nIndex);
|
---|
797 | }
|
---|
798 |
|
---|
799 | INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc)
|
---|
800 | { INT ret;
|
---|
801 | LPSTR sTemp = HEAP_strdupWtoA (GetProcessHeap(),0,szPath);
|
---|
802 |
|
---|
803 | WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc);
|
---|
804 |
|
---|
805 | ret = SIC_GetIconIndex(sTemp, nIndex);
|
---|
806 | HeapFree(GetProcessHeap(),0,sTemp);
|
---|
807 | return ret;
|
---|
808 | }
|
---|
809 |
|
---|
810 | INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc)
|
---|
811 | { if( VERSION_OsIsUnicode())
|
---|
812 | return Shell_GetCachedImageIndexW((LPWSTR)szPath, nIndex, bSimulateDoc);
|
---|
813 | return Shell_GetCachedImageIndexA((LPSTR)szPath, nIndex, bSimulateDoc);
|
---|
814 | }
|
---|
815 |
|
---|
816 | /*************************************************************************
|
---|
817 | * ExtracticonExAW [shell32.189]
|
---|
818 | */
|
---|
819 | HICON WINAPI ExtractIconExAW ( LPCVOID lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons )
|
---|
820 | { if (VERSION_OsIsUnicode())
|
---|
821 | return ExtractIconExW ( (LPWSTR)lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
|
---|
822 | return ExtractIconExA ( (LPSTR)lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
|
---|
823 | }
|
---|
824 | /*************************************************************************
|
---|
825 | * ExtracticonExA [shell32.190]
|
---|
826 | * RETURNS
|
---|
827 | * 0 no icon found
|
---|
828 | * 1 file is not valid
|
---|
829 | * HICON handle of a icon (phiconLarge/Small == NULL)
|
---|
830 | */
|
---|
831 | HICON WINAPI ExtractIconExA ( LPCSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons )
|
---|
832 | { HICON ret=0;
|
---|
833 |
|
---|
834 | TRACE("file=%s idx=%i %p %p num=%i\n", lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons );
|
---|
835 |
|
---|
836 | if (nIconIndex==-1) /* Number of icons requested */
|
---|
837 | return ICO_ExtractIconEx(lpszFile, NULL, -1, 0, 0, 0 );
|
---|
838 |
|
---|
839 |
|
---|
840 | if (phiconLarge)
|
---|
841 | { ret = ICO_ExtractIconEx(lpszFile, phiconLarge, nIconIndex, nIcons, 32, 32 );
|
---|
842 | if ( nIcons==1)
|
---|
843 | { ret = phiconLarge[0];
|
---|
844 | }
|
---|
845 | }
|
---|
846 |
|
---|
847 | /* if no pointers given and one icon expected, return the handle directly*/
|
---|
848 | if (!phiconLarge && ! phiconSmall && nIcons==1 )
|
---|
849 | phiconSmall = &ret;
|
---|
850 |
|
---|
851 | if (phiconSmall)
|
---|
852 | { ret = ICO_ExtractIconEx(lpszFile, phiconSmall, nIconIndex, nIcons, 16, 16 );
|
---|
853 | if ( nIcons==1 )
|
---|
854 | { ret = phiconSmall[0];
|
---|
855 | }
|
---|
856 | }
|
---|
857 |
|
---|
858 | return ret;
|
---|
859 | }
|
---|
860 | /*************************************************************************
|
---|
861 | * ExtracticonExW [shell32.191]
|
---|
862 | */
|
---|
863 | HICON WINAPI ExtractIconExW ( LPCWSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons )
|
---|
864 | { LPSTR sFile;
|
---|
865 | DWORD ret;
|
---|
866 |
|
---|
867 | TRACE("file=%s idx=%i %p %p num=%i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons );
|
---|
868 |
|
---|
869 | sFile = HEAP_strdupWtoA (GetProcessHeap(),0,lpszFile);
|
---|
870 | ret = ExtractIconExA ( sFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
|
---|
871 | HeapFree(GetProcessHeap(),0,sFile);
|
---|
872 | return ret;
|
---|
873 | }
|
---|