xref: /reactos/dll/win32/shell32/wine/shell32_main.c (revision 845faec4)
1 /*
2  *                 Shell basics
3  *
4  * Copyright 1998 Marcus Meissner
5  * Copyright 1998 Juergen Schmied (jsch)  *  <juergen.schmied@metronet.de>
6  * Copyright 2017 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 #include <wine/config.h>
24 
25 #define WIN32_NO_STATUS
26 #define _INC_WINDOWS
27 #define COBJMACROS
28 
29 #include <windef.h>
30 #include <winbase.h>
31 #include <shellapi.h>
32 #include <shlobj.h>
33 #include <shlwapi.h>
34 
35 #include "undocshell.h"
36 #include "pidl.h"
37 #include "shell32_main.h"
38 #include "shresdef.h"
39 
40 #include <wine/debug.h>
41 #include <wine/unicode.h>
42 
43 #include <reactos/version.h>
44 
45 WINE_DEFAULT_DEBUG_CHANNEL(shell);
46 
47 const char * const SHELL_Authors[] = { "Copyright 1993-"COPYRIGHT_YEAR" WINE team", "Copyright 1998-"COPYRIGHT_YEAR" ReactOS Team", 0 };
48 
49 /*************************************************************************
50  * CommandLineToArgvW            [SHELL32.@]
51  *
52  * We must interpret the quotes in the command line to rebuild the argv
53  * array correctly:
54  * - arguments are separated by spaces or tabs
55  * - quotes serve as optional argument delimiters
56  *   '"a b"'   -> 'a b'
57  * - escaped quotes must be converted back to '"'
58  *   '\"'      -> '"'
59  * - consecutive backslashes preceding a quote see their number halved with
60  *   the remainder escaping the quote:
61  *   2n   backslashes + quote -> n backslashes + quote as an argument delimiter
62  *   2n+1 backslashes + quote -> n backslashes + literal quote
63  * - backslashes that are not followed by a quote are copied literally:
64  *   'a\b'     -> 'a\b'
65  *   'a\\b'    -> 'a\\b'
66  * - in quoted strings, consecutive quotes see their number divided by three
67  *   with the remainder modulo 3 deciding whether to close the string or not.
68  *   Note that the opening quote must be counted in the consecutive quotes,
69  *   that's the (1+) below:
70  *   (1+) 3n   quotes -> n quotes
71  *   (1+) 3n+1 quotes -> n quotes plus closes the quoted string
72  *   (1+) 3n+2 quotes -> n+1 quotes plus closes the quoted string
73  * - in unquoted strings, the first quote opens the quoted string and the
74  *   remaining consecutive quotes follow the above rule.
75  */
76 LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
77 {
78     DWORD argc;
79     LPWSTR  *argv;
80     LPCWSTR s;
81     LPWSTR d;
82     LPWSTR cmdline;
83     int qcount,bcount;
84 
85     if(!numargs)
86     {
87         SetLastError(ERROR_INVALID_PARAMETER);
88         return NULL;
89     }
90 
91     if (*lpCmdline==0)
92     {
93         /* Return the path to the executable */
94         DWORD len, deslen=MAX_PATH, size;
95 
96         size = sizeof(LPWSTR)*2 + deslen*sizeof(WCHAR);
97         for (;;)
98         {
99             if (!(argv = LocalAlloc(LMEM_FIXED, size))) return NULL;
100             len = GetModuleFileNameW(0, (LPWSTR)(argv+2), deslen);
101             if (!len)
102             {
103                 LocalFree(argv);
104                 return NULL;
105             }
106             if (len < deslen) break;
107             deslen*=2;
108             size = sizeof(LPWSTR)*2 + deslen*sizeof(WCHAR);
109             LocalFree( argv );
110         }
111         argv[0]=(LPWSTR)(argv+2);
112         argv[1]=NULL;
113         *numargs=1;
114 
115         return argv;
116     }
117 
118     /* --- First count the arguments */
119     argc=1;
120     s=lpCmdline;
121     /* The first argument, the executable path, follows special rules */
122     if (*s=='"')
123     {
124         /* The executable path ends at the next quote, no matter what */
125         s++;
126         while (*s)
127             if (*s++=='"')
128                 break;
129     }
130     else
131     {
132         /* The executable path ends at the next space, no matter what */
133         while (*s && *s!=' ' && *s!='\t')
134             s++;
135     }
136     /* skip to the first argument, if any */
137     while (*s==' ' || *s=='\t')
138         s++;
139     if (*s)
140         argc++;
141 
142     /* Analyze the remaining arguments */
143     qcount=bcount=0;
144     while (*s)
145     {
146         if ((*s==' ' || *s=='\t') && qcount==0)
147         {
148             /* skip to the next argument and count it if any */
149             while (*s==' ' || *s=='\t')
150                 s++;
151             if (*s)
152                 argc++;
153             bcount=0;
154         }
155         else if (*s=='\\')
156         {
157             /* '\', count them */
158             bcount++;
159             s++;
160         }
161         else if (*s=='"')
162         {
163             /* '"' */
164             if ((bcount & 1)==0)
165                 qcount++; /* unescaped '"' */
166             s++;
167             bcount=0;
168             /* consecutive quotes, see comment in copying code below */
169             while (*s=='"')
170             {
171                 qcount++;
172                 s++;
173             }
174             qcount=qcount % 3;
175             if (qcount==2)
176                 qcount=0;
177         }
178         else
179         {
180             /* a regular character */
181             bcount=0;
182             s++;
183         }
184     }
185 
186     /* Allocate in a single lump, the string array, and the strings that go
187      * with it. This way the caller can make a single LocalFree() call to free
188      * both, as per MSDN.
189      */
190     argv=LocalAlloc(LMEM_FIXED, (argc+1)*sizeof(LPWSTR)+(strlenW(lpCmdline)+1)*sizeof(WCHAR));
191     if (!argv)
192         return NULL;
193     cmdline=(LPWSTR)(argv+argc+1);
194     strcpyW(cmdline, lpCmdline);
195 
196     /* --- Then split and copy the arguments */
197     argv[0]=d=cmdline;
198     argc=1;
199     /* The first argument, the executable path, follows special rules */
200     if (*d=='"')
201     {
202         /* The executable path ends at the next quote, no matter what */
203         s=d+1;
204         while (*s)
205         {
206             if (*s=='"')
207             {
208                 s++;
209                 break;
210             }
211             *d++=*s++;
212         }
213     }
214     else
215     {
216         /* The executable path ends at the next space, no matter what */
217         while (*d && *d!=' ' && *d!='\t')
218             d++;
219         s=d;
220         if (*s)
221             s++;
222     }
223     /* close the executable path */
224     *d++=0;
225     /* skip to the first argument and initialize it if any */
226     while (*s==' ' || *s=='\t')
227         s++;
228     if (!*s)
229     {
230         /* There are no parameters so we are all done */
231         argv[argc]=NULL;
232         *numargs=argc;
233         return argv;
234     }
235 
236     /* Split and copy the remaining arguments */
237     argv[argc++]=d;
238     qcount=bcount=0;
239     while (*s)
240     {
241         if ((*s==' ' || *s=='\t') && qcount==0)
242         {
243             /* close the argument */
244             *d++=0;
245             bcount=0;
246 
247             /* skip to the next one and initialize it if any */
248             do {
249                 s++;
250             } while (*s==' ' || *s=='\t');
251             if (*s)
252                 argv[argc++]=d;
253         }
254         else if (*s=='\\')
255         {
256             *d++=*s++;
257             bcount++;
258         }
259         else if (*s=='"')
260         {
261             if ((bcount & 1)==0)
262             {
263                 /* Preceded by an even number of '\', this is half that
264                  * number of '\', plus a quote which we erase.
265                  */
266                 d-=bcount/2;
267                 qcount++;
268             }
269             else
270             {
271                 /* Preceded by an odd number of '\', this is half that
272                  * number of '\' followed by a '"'
273                  */
274                 d=d-bcount/2-1;
275                 *d++='"';
276             }
277             s++;
278             bcount=0;
279             /* Now count the number of consecutive quotes. Note that qcount
280              * already takes into account the opening quote if any, as well as
281              * the quote that lead us here.
282              */
283             while (*s=='"')
284             {
285                 if (++qcount==3)
286                 {
287                     *d++='"';
288                     qcount=0;
289                 }
290                 s++;
291             }
292             if (qcount==2)
293                 qcount=0;
294         }
295         else
296         {
297             /* a regular character */
298             *d++=*s++;
299             bcount=0;
300         }
301     }
302     *d='\0';
303     argv[argc]=NULL;
304     *numargs=argc;
305 
306     return argv;
307 }
308 
309 static DWORD shgfi_get_exe_type(LPCWSTR szFullPath)
310 {
311     BOOL status = FALSE;
312     HANDLE hfile;
313     DWORD BinaryType;
314     IMAGE_DOS_HEADER mz_header;
315     IMAGE_NT_HEADERS nt;
316     DWORD len;
317     char magic[4];
318 
319     status = GetBinaryTypeW (szFullPath, &BinaryType);
320     if (!status)
321         return 0;
322     if (BinaryType == SCS_DOS_BINARY || BinaryType == SCS_PIF_BINARY)
323         return 0x4d5a;
324 
325     hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ,
326                          NULL, OPEN_EXISTING, 0, 0 );
327     if ( hfile == INVALID_HANDLE_VALUE )
328         return 0;
329 
330     /*
331      * The next section is adapted from MODULE_GetBinaryType, as we need
332      * to examine the image header to get OS and version information. We
333      * know from calling GetBinaryTypeA that the image is valid and either
334      * an NE or PE, so much error handling can be omitted.
335      * Seek to the start of the file and read the header information.
336      */
337 
338     SetFilePointer( hfile, 0, NULL, SEEK_SET );
339     ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
340 
341     SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
342     ReadFile( hfile, magic, sizeof(magic), &len, NULL );
343     if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
344     {
345         SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
346         ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
347         CloseHandle( hfile );
348         /* DLL files are not executable and should return 0 */
349         if (nt.FileHeader.Characteristics & IMAGE_FILE_DLL)
350             return 0;
351         if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI)
352         {
353              return IMAGE_NT_SIGNATURE |
354                    (nt.OptionalHeader.MajorSubsystemVersion << 24) |
355                    (nt.OptionalHeader.MinorSubsystemVersion << 16);
356         }
357         return IMAGE_NT_SIGNATURE;
358     }
359     else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
360     {
361         IMAGE_OS2_HEADER ne;
362         SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
363         ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
364         CloseHandle( hfile );
365         if (ne.ne_exetyp == 2)
366             return IMAGE_OS2_SIGNATURE | (ne.ne_expver << 16);
367         return 0;
368     }
369     CloseHandle( hfile );
370     return 0;
371 }
372 
373 /*************************************************************************
374  * SHELL_IsShortcut		[internal]
375  *
376  * Decide if an item id list points to a shell shortcut
377  */
378 BOOL SHELL_IsShortcut(LPCITEMIDLIST pidlLast)
379 {
380     char szTemp[MAX_PATH];
381     HKEY keyCls;
382     BOOL ret = FALSE;
383 
384     if (_ILGetExtension(pidlLast, szTemp, MAX_PATH) &&
385           HCR_MapTypeToValueA(szTemp, szTemp, MAX_PATH, TRUE))
386     {
387         if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_QUERY_VALUE, &keyCls))
388         {
389           if (ERROR_SUCCESS == RegQueryValueExA(keyCls, "IsShortcut", NULL, NULL, NULL, NULL))
390             ret = TRUE;
391 
392           RegCloseKey(keyCls);
393         }
394     }
395 
396     return ret;
397 }
398 
399 #define SHGFI_KNOWN_FLAGS \
400     (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
401      SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
402      SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
403      SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
404      SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
405 
406 /*************************************************************************
407  * SHGetFileInfoW            [SHELL32.@]
408  *
409  */
410 DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
411                                 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags )
412 {
413     WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH];
414     int iIndex;
415     DWORD_PTR ret = TRUE;
416     DWORD dwAttributes = 0;
417     IShellFolder * psfParent = NULL;
418     IExtractIconW * pei = NULL;
419     LPITEMIDLIST    pidlLast = NULL, pidl = NULL;
420     HRESULT hr = S_OK;
421     BOOL IconNotYetLoaded=TRUE;
422     UINT uGilFlags = 0;
423     HIMAGELIST big_icons, small_icons;
424 
425     TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
426           (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
427           psfi, psfi ? psfi->dwAttributes : 0, sizeofpsfi, flags);
428 
429     if (!path)
430         return FALSE;
431 
432     /* windows initializes these values regardless of the flags */
433     if (psfi != NULL)
434     {
435         psfi->szDisplayName[0] = '\0';
436         psfi->szTypeName[0] = '\0';
437         psfi->hIcon = NULL;
438     }
439 
440     if (!(flags & SHGFI_PIDL))
441     {
442         /* SHGetFileInfo should work with absolute and relative paths */
443         if (PathIsRelativeW(path))
444         {
445             GetCurrentDirectoryW(MAX_PATH, szLocation);
446             PathCombineW(szFullPath, szLocation, path);
447         }
448         else
449         {
450             lstrcpynW(szFullPath, path, MAX_PATH);
451         }
452     }
453     else
454     {
455         SHGetPathFromIDListW((LPITEMIDLIST)path, szFullPath);
456     }
457 
458     if (flags & SHGFI_EXETYPE)
459     {
460         if (!(flags & SHGFI_SYSICONINDEX))
461         {
462             if (flags & SHGFI_USEFILEATTRIBUTES)
463             {
464                 return TRUE;
465             }
466             else if (GetFileAttributesW(szFullPath) != INVALID_FILE_ATTRIBUTES)
467             {
468                 return shgfi_get_exe_type(szFullPath);
469             }
470         }
471     }
472 
473     /*
474      * psfi is NULL normally to query EXE type. If it is NULL, none of the
475      * below makes sense anyway. Windows allows this and just returns FALSE
476      */
477     if (psfi == NULL)
478         return FALSE;
479 
480     /*
481      * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
482      * is not specified.
483      * The pidl functions fail on not existing file names
484      */
485 
486     if (flags & SHGFI_PIDL)
487     {
488         pidl = ILClone((LPCITEMIDLIST)path);
489     }
490     else if (!(flags & SHGFI_USEFILEATTRIBUTES))
491     {
492         hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes);
493     }
494 
495     if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES))
496     {
497         /* get the parent shellfolder */
498         if (pidl)
499         {
500             hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent,
501                                 (LPCITEMIDLIST*)&pidlLast );
502             if (SUCCEEDED(hr))
503                 pidlLast = ILClone(pidlLast);
504             else
505                 hr = S_OK;
506             ILFree(pidl);
507         }
508         else
509         {
510             ERR("pidl is null!\n");
511             return FALSE;
512         }
513     }
514 
515     /* get the attributes of the child */
516     if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
517     {
518         if (!(flags & SHGFI_ATTR_SPECIFIED))
519         {
520             psfi->dwAttributes = 0xffffffff;
521         }
522         if (psfParent)
523         {
524             IShellFolder_GetAttributesOf(psfParent, 1, (LPCITEMIDLIST*)&pidlLast,
525                                          &(psfi->dwAttributes));
526         }
527     }
528 
529     if (flags & SHGFI_USEFILEATTRIBUTES)
530     {
531         if (flags & SHGFI_ICON)
532         {
533             psfi->dwAttributes = 0;
534         }
535     }
536 
537     /* get the displayname */
538     if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
539     {
540         if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
541         {
542             lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath));
543         }
544         else if (psfParent)
545         {
546             STRRET str;
547             hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast,
548                                                 SHGDN_INFOLDER, &str);
549             StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
550         }
551     }
552 
553     /* get the type name */
554     if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
555     {
556         static const WCHAR szFile[] = { 'F','i','l','e',0 };
557         static const WCHAR szDashFile[] = { '-','f','i','l','e',0 };
558 
559         if (!(flags & SHGFI_USEFILEATTRIBUTES) || (flags & SHGFI_PIDL))
560         {
561             char ftype[80];
562 
563             _ILGetFileType(pidlLast, ftype, 80);
564             MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 );
565         }
566         else
567         {
568             if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
569                 strcatW (psfi->szTypeName, szFile);
570             else
571             {
572                 WCHAR sTemp[64];
573 
574                 lstrcpyW(sTemp,PathFindExtensionW(szFullPath));
575                 if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) &&
576                     HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE )))
577                 {
578                     lstrcpynW (psfi->szTypeName, sTemp, 64);
579                     strcatW (psfi->szTypeName, szDashFile);
580                 }
581             }
582         }
583     }
584 
585     /* ### icons ###*/
586 
587     Shell_GetImageLists( &big_icons, &small_icons );
588 
589     if (flags & SHGFI_OPENICON)
590         uGilFlags |= GIL_OPENICON;
591 
592     if (flags & SHGFI_LINKOVERLAY)
593         uGilFlags |= GIL_FORSHORTCUT;
594     else if ((flags&SHGFI_ADDOVERLAYS) ||
595              (flags&(SHGFI_ICON|SHGFI_SMALLICON))==SHGFI_ICON)
596     {
597         if (SHELL_IsShortcut(pidlLast))
598             uGilFlags |= GIL_FORSHORTCUT;
599     }
600 
601     if (flags & SHGFI_OVERLAYINDEX)
602         FIXME("SHGFI_OVERLAYINDEX unhandled\n");
603 
604     if (flags & SHGFI_SELECTED)
605         FIXME("set icon to selected, stub\n");
606 
607     if (flags & SHGFI_SHELLICONSIZE)
608         FIXME("set icon to shell size, stub\n");
609 
610     /* get the iconlocation */
611     if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
612     {
613         UINT uDummy,uFlags;
614 
615         if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
616         {
617             if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
618             {
619                 lstrcpyW(psfi->szDisplayName, swShell32Name);
620                 psfi->iIcon = -IDI_SHELL_FOLDER;
621             }
622             else
623             {
624                 WCHAR* szExt;
625                 static const WCHAR p1W[] = {'%','1',0};
626                 WCHAR sTemp [MAX_PATH];
627 
628                 szExt = PathFindExtensionW(szFullPath);
629                 TRACE("szExt=%s\n", debugstr_w(szExt));
630                 if ( szExt &&
631                      HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
632                      HCR_GetIconW(sTemp, sTemp, NULL, MAX_PATH, &psfi->iIcon))
633                 {
634                     if (lstrcmpW(p1W, sTemp))
635                         strcpyW(psfi->szDisplayName, sTemp);
636                     else
637                     {
638                         /* the icon is in the file */
639                         strcpyW(psfi->szDisplayName, szFullPath);
640                     }
641                 }
642                 else
643                     ret = FALSE;
644             }
645         }
646         else if (psfParent)
647         {
648             hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1,
649                 (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW,
650                 &uDummy, (LPVOID*)&pei);
651             if (SUCCEEDED(hr))
652             {
653                 hr = IExtractIconW_GetIconLocation(pei, uGilFlags,
654                     szLocation, MAX_PATH, &iIndex, &uFlags);
655 
656                 if (uFlags & GIL_NOTFILENAME)
657                     ret = FALSE;
658                 else
659                 {
660                     lstrcpyW (psfi->szDisplayName, szLocation);
661                     psfi->iIcon = iIndex;
662                 }
663                 IExtractIconW_Release(pei);
664             }
665         }
666     }
667 
668     /* get icon index (or load icon)*/
669     if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
670     {
671         if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
672         {
673             WCHAR sTemp [MAX_PATH];
674             WCHAR * szExt;
675             int icon_idx=0;
676 
677             lstrcpynW(sTemp, szFullPath, MAX_PATH);
678 
679             if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
680                 psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER, 0);
681             else
682             {
683                 static const WCHAR p1W[] = {'%','1',0};
684 
685                 psfi->iIcon = 0;
686                 szExt = PathFindExtensionW(sTemp);
687                 if ( szExt &&
688                      HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
689                      HCR_GetIconW(sTemp, sTemp, NULL, MAX_PATH, &icon_idx))
690                 {
691                     if (!lstrcmpW(p1W,sTemp))            /* icon is in the file */
692                         strcpyW(sTemp, szFullPath);
693 
694                     if (flags & SHGFI_SYSICONINDEX)
695                     {
696                         psfi->iIcon = SIC_GetIconIndex(sTemp,icon_idx,0);
697                         if (psfi->iIcon == -1)
698                             psfi->iIcon = 0;
699                     }
700                     else
701                     {
702                         UINT ret;
703                         if (flags & SHGFI_SMALLICON)
704                             ret = PrivateExtractIconsW( sTemp,icon_idx,
705                                 GetSystemMetrics( SM_CXSMICON ),
706                                 GetSystemMetrics( SM_CYSMICON ),
707                                 &psfi->hIcon, 0, 1, 0);
708                         else
709                             ret = PrivateExtractIconsW( sTemp, icon_idx,
710                                 GetSystemMetrics( SM_CXICON),
711                                 GetSystemMetrics( SM_CYICON),
712                                 &psfi->hIcon, 0, 1, 0);
713                         if (ret != 0 && ret != (UINT)-1)
714                         {
715                             IconNotYetLoaded=FALSE;
716                             psfi->iIcon = icon_idx;
717                         }
718                     }
719                 }
720             }
721         }
722         else if (psfParent)
723         {
724             if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON),
725                 uGilFlags, &(psfi->iIcon))))
726             {
727                 ret = FALSE;
728             }
729         }
730         if (ret && (flags & SHGFI_SYSICONINDEX))
731         {
732             if (flags & SHGFI_SMALLICON)
733                 ret = (DWORD_PTR)small_icons;
734             else
735                 ret = (DWORD_PTR)big_icons;
736         }
737     }
738 
739     /* icon handle */
740     if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
741     {
742         if (flags & SHGFI_SMALLICON)
743             psfi->hIcon = ImageList_GetIcon( small_icons, psfi->iIcon, ILD_NORMAL);
744         else
745             psfi->hIcon = ImageList_GetIcon( big_icons, psfi->iIcon, ILD_NORMAL);
746     }
747 
748     if (flags & ~SHGFI_KNOWN_FLAGS)
749         FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS);
750 
751     if (psfParent)
752         IShellFolder_Release(psfParent);
753 
754     if (hr != S_OK)
755         ret = FALSE;
756 
757     SHFree(pidlLast);
758 
759     TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
760            psfi->hIcon, psfi->iIcon, psfi->dwAttributes,
761            debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret);
762 
763     return ret;
764 }
765 
766 /*************************************************************************
767  * SHGetFileInfoA            [SHELL32.@]
768  *
769  * Note:
770  *    MSVBVM60.__vbaNew2 expects this function to return a value in range
771  *    1 .. 0x7fff when the function succeeds and flags does not contain
772  *    SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
773  */
774 DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
775                                 SHFILEINFOA *psfi, UINT sizeofpsfi,
776                                 UINT flags )
777 {
778     INT len;
779     LPWSTR temppath = NULL;
780     LPCWSTR pathW;
781     DWORD_PTR ret;
782     SHFILEINFOW temppsfi;
783 
784     if (flags & SHGFI_PIDL)
785     {
786         /* path contains a pidl */
787         pathW = (LPCWSTR)path;
788     }
789     else
790     {
791         len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
792         temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
793         MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
794         pathW = temppath;
795     }
796 
797     if (psfi)
798     {
799         temppsfi.hIcon = psfi->hIcon;
800         temppsfi.iIcon = psfi->iIcon;
801         temppsfi.dwAttributes = psfi->dwAttributes;
802 
803         ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
804         psfi->hIcon = temppsfi.hIcon;
805         psfi->iIcon = temppsfi.iIcon;
806         psfi->dwAttributes = temppsfi.dwAttributes;
807 
808         WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1,
809               psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
810 
811         WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1,
812               psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
813     }
814     else
815         ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, 0, flags);
816 
817     HeapFree(GetProcessHeap(), 0, temppath);
818 
819     return ret;
820 }
821 
822 /*************************************************************************
823  * DuplicateIcon            [SHELL32.@]
824  */
825 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
826 {
827     ICONINFO IconInfo;
828     HICON hDupIcon = 0;
829 
830     TRACE("%p %p\n", hInstance, hIcon);
831 
832     if (GetIconInfo(hIcon, &IconInfo))
833     {
834         hDupIcon = CreateIconIndirect(&IconInfo);
835 
836         /* clean up hbmMask and hbmColor */
837         DeleteObject(IconInfo.hbmMask);
838         DeleteObject(IconInfo.hbmColor);
839     }
840 
841     return hDupIcon;
842 }
843 
844 /*************************************************************************
845  * ExtractIconA                [SHELL32.@]
846  */
847 HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex)
848 {
849     HICON ret;
850     INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
851     LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
852 
853     TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex);
854 
855     MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
856     ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex);
857     HeapFree(GetProcessHeap(), 0, lpwstrFile);
858 
859     return ret;
860 }
861 
862 /*************************************************************************
863  * ExtractIconW                [SHELL32.@]
864  */
865 HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
866 {
867     HICON  hIcon = NULL;
868     UINT ret;
869     UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON);
870 
871     TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex);
872 
873     if (nIconIndex == (UINT)-1)
874     {
875         ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR);
876         if (ret != (UINT)-1 && ret)
877             return (HICON)(UINT_PTR)ret;
878         return NULL;
879     }
880     else
881         ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR);
882 
883     if (ret == (UINT)-1)
884         return (HICON)1;
885     else if (ret > 0 && hIcon)
886         return hIcon;
887 
888     return NULL;
889 }
890 
891 /*************************************************************************
892  * Printer_LoadIconsW        [SHELL32.205]
893  */
894 VOID WINAPI Printer_LoadIconsW(LPCWSTR wsPrinterName, HICON * pLargeIcon, HICON * pSmallIcon)
895 {
896     INT iconindex=IDI_SHELL_PRINTERS_FOLDER;
897 
898     TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName), pLargeIcon, pSmallIcon);
899 
900     /* We should check if wsPrinterName is
901        1. the Default Printer or not
902        2. connected or not
903        3. a Local Printer or a Network-Printer
904        and use different Icons
905     */
906     if((wsPrinterName != NULL) && (wsPrinterName[0] != 0))
907     {
908         FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName));
909     }
910 
911     if(pLargeIcon != NULL)
912         *pLargeIcon = LoadImageW(shell32_hInstance,
913                                  (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
914                                  0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE);
915 
916     if(pSmallIcon != NULL)
917         *pSmallIcon = LoadImageW(shell32_hInstance,
918                                  (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
919                                  16, 16, LR_DEFAULTCOLOR);
920 }
921 
922 /*************************************************************************
923  * Printers_RegisterWindowW        [SHELL32.213]
924  * used by "printui.dll":
925  * find the Window of the given Type for the specific Printer and
926  * return the already existent hwnd or open a new window
927  */
928 BOOL WINAPI Printers_RegisterWindowW(LPCWSTR wsPrinter, DWORD dwType,
929             HANDLE * phClassPidl, HWND * phwnd)
930 {
931     FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter), dwType,
932                 phClassPidl, (phClassPidl != NULL) ? *(phClassPidl) : NULL,
933                 phwnd, (phwnd != NULL) ? *(phwnd) : NULL);
934 
935     return FALSE;
936 }
937 
938 /*************************************************************************
939  * Printers_UnregisterWindow      [SHELL32.214]
940  */
941 VOID WINAPI Printers_UnregisterWindow(HANDLE hClassPidl, HWND hwnd)
942 {
943     FIXME("(%p, %p) stub!\n", hClassPidl, hwnd);
944 }
945 
946 /*************************************************************************/
947 
948 typedef struct
949 {
950     LPCWSTR  szApp;
951     LPCWSTR  szOtherStuff;
952     HICON hIcon;
953 } ABOUT_INFO;
954 
955 #define DROP_FIELD_TOP    (-15)
956 #define DROP_FIELD_HEIGHT  15
957 
958 /*************************************************************************
959  * SHAppBarMessage            [SHELL32.@]
960  */
961 UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
962 {
963     int width=data->rc.right - data->rc.left;
964     int height=data->rc.bottom - data->rc.top;
965     RECT rec=data->rc;
966 
967     TRACE("msg=%d, data={cb=%d, hwnd=%p, callback=%x, edge=%d, rc=%s, lparam=%lx}\n",
968           msg, data->cbSize, data->hWnd, data->uCallbackMessage, data->uEdge,
969           wine_dbgstr_rect(&data->rc), data->lParam);
970 
971     switch (msg)
972     {
973         case ABM_GETSTATE:
974             return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
975 
976         case ABM_GETTASKBARPOS:
977             GetWindowRect(data->hWnd, &rec);
978             data->rc=rec;
979             return TRUE;
980 
981         case ABM_ACTIVATE:
982             SetActiveWindow(data->hWnd);
983             return TRUE;
984 
985         case ABM_GETAUTOHIDEBAR:
986             return 0; /* pretend there is no autohide bar */
987 
988         case ABM_NEW:
989             /* cbSize, hWnd, and uCallbackMessage are used. All other ignored */
990             SetWindowPos(data->hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
991             return TRUE;
992 
993         case ABM_QUERYPOS:
994             GetWindowRect(data->hWnd, &(data->rc));
995             return TRUE;
996 
997         case ABM_REMOVE:
998             FIXME("ABM_REMOVE broken\n");
999             /* FIXME: this is wrong; should it be DestroyWindow instead? */
1000             /*CloseHandle(data->hWnd);*/
1001             return TRUE;
1002 
1003         case ABM_SETAUTOHIDEBAR:
1004             SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
1005                              width,height,SWP_SHOWWINDOW);
1006             return TRUE;
1007 
1008         case ABM_SETPOS:
1009             data->uEdge=(ABE_RIGHT | ABE_LEFT);
1010             SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
1011                          width,height,SWP_SHOWWINDOW);
1012             return TRUE;
1013 
1014         case ABM_WINDOWPOSCHANGED:
1015             return TRUE;
1016     }
1017 
1018     return FALSE;
1019 }
1020 
1021 /*************************************************************************
1022  * SHHelpShortcuts_RunDLLA        [SHELL32.@]
1023  *
1024  */
1025 DWORD WINAPI SHHelpShortcuts_RunDLLA(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
1026 {
1027     FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
1028     return 0;
1029 }
1030 
1031 /*************************************************************************
1032  * SHHelpShortcuts_RunDLLA        [SHELL32.@]
1033  *
1034  */
1035 DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
1036 {
1037     FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
1038     return 0;
1039 }
1040 
1041 /*************************************************************************
1042  * SHLoadInProc                [SHELL32.@]
1043  * Create an instance of specified object class from within
1044  * the shell process and release it immediately
1045  */
1046 HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
1047 {
1048     void *ptr = NULL;
1049 
1050     TRACE("%s\n", debugstr_guid(rclsid));
1051 
1052     CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
1053     if(ptr)
1054     {
1055         IUnknown * pUnk = ptr;
1056         IUnknown_Release(pUnk);
1057         return S_OK;
1058     }
1059     return DISP_E_MEMBERNOTFOUND;
1060 }
1061 
1062 static VOID SetRegTextData(HWND hWnd, HKEY hKey, LPCWSTR Value, UINT uID)
1063 {
1064     DWORD dwBufferSize;
1065     DWORD dwType;
1066     LPWSTR lpBuffer;
1067 
1068     if( RegQueryValueExW(hKey, Value, NULL, &dwType, NULL, &dwBufferSize) == ERROR_SUCCESS )
1069     {
1070         if(dwType == REG_SZ)
1071         {
1072             lpBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwBufferSize);
1073 
1074             if(lpBuffer)
1075             {
1076                 if( RegQueryValueExW(hKey, Value, NULL, &dwType, (LPBYTE)lpBuffer, &dwBufferSize) == ERROR_SUCCESS )
1077                 {
1078                     SetDlgItemTextW(hWnd, uID, lpBuffer);
1079                 }
1080 
1081                 HeapFree(GetProcessHeap(), 0, lpBuffer);
1082             }
1083         }
1084     }
1085 }
1086 
1087 INT_PTR CALLBACK AboutAuthorsDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
1088 {
1089     switch(msg)
1090     {
1091         case WM_INITDIALOG:
1092         {
1093             const char* const *pstr = SHELL_Authors;
1094 
1095             // Add the authors to the list
1096             SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, WM_SETREDRAW, FALSE, 0 );
1097 
1098             while (*pstr)
1099             {
1100                 WCHAR name[64];
1101 
1102                 /* authors list is in utf-8 format */
1103                 MultiByteToWideChar( CP_UTF8, 0, *pstr, -1, name, sizeof(name)/sizeof(WCHAR) );
1104                 SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, LB_ADDSTRING, (WPARAM)-1, (LPARAM)name );
1105                 pstr++;
1106             }
1107 
1108             SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, WM_SETREDRAW, TRUE, 0 );
1109 
1110             return TRUE;
1111         }
1112     }
1113 
1114     return FALSE;
1115 }
1116 /*************************************************************************
1117  * AboutDlgProc            (internal)
1118  */
1119 static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
1120 {
1121     static DWORD   cxLogoBmp;
1122     static DWORD   cyLogoBmp;
1123     static HBITMAP hLogoBmp;
1124     static HWND    hWndAuthors;
1125 
1126     switch(msg)
1127     {
1128         case WM_INITDIALOG:
1129         {
1130             ABOUT_INFO *info = (ABOUT_INFO *)lParam;
1131 
1132             if (info)
1133             {
1134                 const WCHAR szRegKey[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
1135                 HKEY hRegKey;
1136                 MEMORYSTATUSEX MemStat;
1137                 WCHAR szAppTitle[512];
1138                 WCHAR szAppTitleTemplate[512];
1139                 WCHAR szAuthorsText[20];
1140 
1141                 // Preload the ROS bitmap
1142                 hLogoBmp = (HBITMAP)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IDB_REACTOS), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
1143 
1144                 if(hLogoBmp)
1145                 {
1146                     BITMAP bmpLogo;
1147 
1148                     GetObject( hLogoBmp, sizeof(BITMAP), &bmpLogo );
1149 
1150                     cxLogoBmp = bmpLogo.bmWidth;
1151                     cyLogoBmp = bmpLogo.bmHeight;
1152                 }
1153 
1154                 // Set App-specific stuff (icon, app name, szOtherStuff string)
1155                 SendDlgItemMessageW(hWnd, IDC_ABOUT_ICON, STM_SETICON, (WPARAM)info->hIcon, 0);
1156 
1157                 GetWindowTextW( hWnd, szAppTitleTemplate, sizeof(szAppTitleTemplate) / sizeof(WCHAR) );
1158                 swprintf( szAppTitle, szAppTitleTemplate, info->szApp );
1159                 SetWindowTextW( hWnd, szAppTitle );
1160 
1161                 SetDlgItemTextW( hWnd, IDC_ABOUT_APPNAME, info->szApp );
1162                 SetDlgItemTextW( hWnd, IDC_ABOUT_OTHERSTUFF, info->szOtherStuff );
1163 
1164                 // Set the registered user and organization name
1165                 if(RegOpenKeyExW( HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_QUERY_VALUE, &hRegKey ) == ERROR_SUCCESS)
1166                 {
1167                     SetRegTextData( hWnd, hRegKey, L"RegisteredOwner", IDC_ABOUT_REG_USERNAME );
1168                     SetRegTextData( hWnd, hRegKey, L"RegisteredOrganization", IDC_ABOUT_REG_ORGNAME );
1169 
1170                     RegCloseKey( hRegKey );
1171                 }
1172 
1173                 // Set the value for the installed physical memory
1174                 MemStat.dwLength = sizeof(MemStat);
1175                 if( GlobalMemoryStatusEx(&MemStat) )
1176                 {
1177                     WCHAR szBuf[12];
1178 
1179                     if (MemStat.ullTotalPhys > 1024 * 1024 * 1024)
1180                     {
1181                         double dTotalPhys;
1182                         WCHAR szDecimalSeparator[4];
1183                         WCHAR szUnits[3];
1184 
1185                         // We're dealing with GBs or more
1186                         MemStat.ullTotalPhys /= 1024 * 1024;
1187 
1188                         if (MemStat.ullTotalPhys > 1024 * 1024)
1189                         {
1190                             // We're dealing with TBs or more
1191                             MemStat.ullTotalPhys /= 1024;
1192 
1193                             if (MemStat.ullTotalPhys > 1024 * 1024)
1194                             {
1195                                 // We're dealing with PBs or more
1196                                 MemStat.ullTotalPhys /= 1024;
1197 
1198                                 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1199                                 wcscpy( szUnits, L"PB" );
1200                             }
1201                             else
1202                             {
1203                                 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1204                                 wcscpy( szUnits, L"TB" );
1205                             }
1206                         }
1207                         else
1208                         {
1209                             dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1210                             wcscpy( szUnits, L"GB" );
1211                         }
1212 
1213                         // We need the decimal point of the current locale to display the RAM size correctly
1214                         if (GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL,
1215                             szDecimalSeparator,
1216                             sizeof(szDecimalSeparator) / sizeof(WCHAR)) > 0)
1217                         {
1218                             UCHAR uDecimals;
1219                             UINT uIntegral;
1220 
1221                             uIntegral = (UINT)dTotalPhys;
1222                             uDecimals = (UCHAR)((UINT)(dTotalPhys * 100) - uIntegral * 100);
1223 
1224                             // Display the RAM size with 2 decimals
1225                             swprintf(szBuf, L"%u%s%02u %s", uIntegral, szDecimalSeparator, uDecimals, szUnits);
1226                         }
1227                     }
1228                     else
1229                     {
1230                         // We're dealing with MBs, don't show any decimals
1231                         swprintf( szBuf, L"%u MB", (UINT)MemStat.ullTotalPhys / 1024 / 1024 );
1232                     }
1233 
1234                     SetDlgItemTextW( hWnd, IDC_ABOUT_PHYSMEM, szBuf);
1235                 }
1236 
1237                 // Add the Authors dialog
1238                 hWndAuthors = CreateDialogW( shell32_hInstance, MAKEINTRESOURCEW(IDD_ABOUT_AUTHORS), hWnd, AboutAuthorsDlgProc );
1239                 LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_AUTHORS, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1240                 SetDlgItemTextW( hWnd, IDC_ABOUT_AUTHORS, szAuthorsText );
1241             }
1242 
1243             return TRUE;
1244         }
1245 
1246         case WM_PAINT:
1247         {
1248             if(hLogoBmp)
1249             {
1250                 PAINTSTRUCT ps;
1251                 HDC hdc;
1252                 HDC hdcMem;
1253 
1254                 hdc = BeginPaint(hWnd, &ps);
1255                 hdcMem = CreateCompatibleDC(hdc);
1256 
1257                 if(hdcMem)
1258                 {
1259                     SelectObject(hdcMem, hLogoBmp);
1260                     BitBlt(hdc, 0, 0, cxLogoBmp, cyLogoBmp, hdcMem, 0, 0, SRCCOPY);
1261 
1262                     DeleteDC(hdcMem);
1263                 }
1264 
1265                 EndPaint(hWnd, &ps);
1266             }
1267         }; break;
1268 
1269         case WM_COMMAND:
1270         {
1271             switch(wParam)
1272             {
1273                 case IDOK:
1274                 case IDCANCEL:
1275                     EndDialog(hWnd, TRUE);
1276                     return TRUE;
1277 
1278                 case IDC_ABOUT_AUTHORS:
1279                 {
1280                     static BOOL bShowingAuthors = FALSE;
1281                     WCHAR szAuthorsText[20];
1282 
1283                     if(bShowingAuthors)
1284                     {
1285                         LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_AUTHORS, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1286                         ShowWindow( hWndAuthors, SW_HIDE );
1287                     }
1288                     else
1289                     {
1290                         LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_BACK, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1291                         ShowWindow( hWndAuthors, SW_SHOW );
1292                     }
1293 
1294                     SetDlgItemTextW( hWnd, IDC_ABOUT_AUTHORS, szAuthorsText );
1295                     bShowingAuthors = !bShowingAuthors;
1296                     return TRUE;
1297                 }
1298             }
1299         }; break;
1300 
1301         case WM_CLOSE:
1302             EndDialog(hWnd, TRUE);
1303             break;
1304     }
1305 
1306     return 0;
1307 }
1308 
1309 
1310 /*************************************************************************
1311  * ShellAboutA                [SHELL32.288]
1312  */
1313 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon )
1314 {
1315     BOOL ret;
1316     LPWSTR appW = NULL, otherW = NULL;
1317     int len;
1318 
1319     if (szApp)
1320     {
1321         len = MultiByteToWideChar(CP_ACP, 0, szApp, -1, NULL, 0);
1322         appW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1323         MultiByteToWideChar(CP_ACP, 0, szApp, -1, appW, len);
1324     }
1325     if (szOtherStuff)
1326     {
1327         len = MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, NULL, 0);
1328         otherW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1329         MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, otherW, len);
1330     }
1331 
1332     ret = ShellAboutW(hWnd, appW, otherW, hIcon);
1333 
1334     HeapFree(GetProcessHeap(), 0, otherW);
1335     HeapFree(GetProcessHeap(), 0, appW);
1336     return ret;
1337 }
1338 
1339 
1340 /*************************************************************************
1341  * ShellAboutW                [SHELL32.289]
1342  */
1343 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
1344                          HICON hIcon )
1345 {
1346     ABOUT_INFO info;
1347     HRSRC hRes;
1348     DLGTEMPLATE *DlgTemplate;
1349     BOOL bRet;
1350 
1351     TRACE("\n");
1352 
1353     // DialogBoxIndirectParamW will be called with the hInstance of the calling application, so we have to preload the dialog template
1354     hRes = FindResourceW(shell32_hInstance, MAKEINTRESOURCEW(IDD_ABOUT), (LPWSTR)RT_DIALOG);
1355     if(!hRes)
1356         return FALSE;
1357 
1358     DlgTemplate = (DLGTEMPLATE *)LoadResource(shell32_hInstance, hRes);
1359     if(!DlgTemplate)
1360         return FALSE;
1361 
1362     info.szApp        = szApp;
1363     info.szOtherStuff = szOtherStuff;
1364     info.hIcon        = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
1365 
1366     bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ),
1367                                    DlgTemplate, hWnd, AboutDlgProc, (LPARAM)&info );
1368     return bRet;
1369 }
1370 
1371 /*************************************************************************
1372  * FreeIconList (SHELL32.@)
1373  */
1374 void WINAPI FreeIconList( DWORD dw )
1375 {
1376     FIXME("%x: stub\n",dw);
1377 }
1378 
1379 /*************************************************************************
1380  * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1381  */
1382 HRESULT WINAPI SHLoadNonloadedIconOverlayIdentifiers( VOID )
1383 {
1384     FIXME("stub\n");
1385     return S_OK;
1386 }
1387