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