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