[SHELL32]
[reactos.git] / 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
423 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
424 (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
425 psfi, psfi->dwAttributes, sizeofpsfi, flags);
426
427 if (!path)
428 return FALSE;
429
430 /* windows initializes these values regardless of the flags */
431 if (psfi != NULL)
432 {
433 psfi->szDisplayName[0] = '\0';
434 psfi->szTypeName[0] = '\0';
435 psfi->iIcon = 0;
436 }
437
438 if (!(flags & SHGFI_PIDL))
439 {
440 /* SHGetFileInfo should work with absolute and relative paths */
441 if (PathIsRelativeW(path))
442 {
443 GetCurrentDirectoryW(MAX_PATH, szLocation);
444 PathCombineW(szFullPath, szLocation, path);
445 }
446 else
447 {
448 lstrcpynW(szFullPath, path, MAX_PATH);
449 }
450 }
451
452 if (flags & SHGFI_EXETYPE)
453 {
454 if (flags != SHGFI_EXETYPE)
455 return 0;
456 return shgfi_get_exe_type(szFullPath);
457 }
458
459 /*
460 * psfi is NULL normally to query EXE type. If it is NULL, none of the
461 * below makes sense anyway. Windows allows this and just returns FALSE
462 */
463 if (psfi == NULL)
464 return FALSE;
465
466 /*
467 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
468 * is not specified.
469 * The pidl functions fail on not existing file names
470 */
471
472 if (flags & SHGFI_PIDL)
473 {
474 pidl = ILClone((LPCITEMIDLIST)path);
475 }
476 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
477 {
478 hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes);
479 }
480
481 if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES))
482 {
483 /* get the parent shellfolder */
484 if (pidl)
485 {
486 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent,
487 (LPCITEMIDLIST*)&pidlLast );
488 if (SUCCEEDED(hr))
489 pidlLast = ILClone(pidlLast);
490 ILFree(pidl);
491 }
492 else
493 {
494 ERR("pidl is null!\n");
495 return FALSE;
496 }
497 }
498
499 /* get the attributes of the child */
500 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
501 {
502 if (!(flags & SHGFI_ATTR_SPECIFIED))
503 {
504 psfi->dwAttributes = 0xffffffff;
505 }
506 if (psfParent)
507 IShellFolder_GetAttributesOf( psfParent, 1, (LPCITEMIDLIST*)&pidlLast,
508 &(psfi->dwAttributes) );
509 }
510
511 /* get the displayname */
512 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
513 {
514 if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
515 {
516 lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath));
517 }
518 else
519 {
520 STRRET str;
521 hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast,
522 SHGDN_INFOLDER, &str);
523 StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
524 }
525 }
526
527 /* get the type name */
528 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
529 {
530 static const WCHAR szFile[] = { 'F','i','l','e',0 };
531 static const WCHAR szDashFile[] = { '-','f','i','l','e',0 };
532
533 if (!(flags & SHGFI_USEFILEATTRIBUTES) || (flags & SHGFI_PIDL))
534 {
535 char ftype[80];
536
537 _ILGetFileType(pidlLast, ftype, 80);
538 MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 );
539 }
540 else
541 {
542 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
543 strcatW (psfi->szTypeName, szFile);
544 else
545 {
546 WCHAR sTemp[64];
547
548 lstrcpyW(sTemp,PathFindExtensionW(szFullPath));
549 if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) &&
550 HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE )))
551 {
552 lstrcpynW (psfi->szTypeName, sTemp, 64);
553 strcatW (psfi->szTypeName, szDashFile);
554 }
555 }
556 }
557 }
558
559 /* ### icons ###*/
560 if (flags & SHGFI_OPENICON)
561 uGilFlags |= GIL_OPENICON;
562
563 if (flags & SHGFI_LINKOVERLAY)
564 uGilFlags |= GIL_FORSHORTCUT;
565 else if ((flags&SHGFI_ADDOVERLAYS) ||
566 (flags&(SHGFI_ICON|SHGFI_SMALLICON))==SHGFI_ICON)
567 {
568 if (SHELL_IsShortcut(pidlLast))
569 uGilFlags |= GIL_FORSHORTCUT;
570 }
571
572 if (flags & SHGFI_OVERLAYINDEX)
573 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
574
575 if (flags & SHGFI_SELECTED)
576 FIXME("set icon to selected, stub\n");
577
578 if (flags & SHGFI_SHELLICONSIZE)
579 FIXME("set icon to shell size, stub\n");
580
581 /* get the iconlocation */
582 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
583 {
584 UINT uDummy,uFlags;
585
586 if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
587 {
588 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
589 {
590 lstrcpyW(psfi->szDisplayName, swShell32Name);
591 psfi->iIcon = -IDI_SHELL_FOLDER;
592 }
593 else
594 {
595 WCHAR* szExt;
596 static const WCHAR p1W[] = {'%','1',0};
597 WCHAR sTemp [MAX_PATH];
598
599 szExt = PathFindExtensionW(szFullPath);
600 TRACE("szExt=%s\n", debugstr_w(szExt));
601 if ( szExt &&
602 HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
603 HCR_GetIconW(sTemp, sTemp, NULL, MAX_PATH, &psfi->iIcon))
604 {
605 if (lstrcmpW(p1W, sTemp))
606 strcpyW(psfi->szDisplayName, sTemp);
607 else
608 {
609 /* the icon is in the file */
610 strcpyW(psfi->szDisplayName, szFullPath);
611 }
612 }
613 else
614 ret = FALSE;
615 }
616 }
617 else
618 {
619 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1,
620 (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW,
621 &uDummy, (LPVOID*)&pei);
622 if (SUCCEEDED(hr))
623 {
624 hr = IExtractIconW_GetIconLocation(pei, uGilFlags,
625 szLocation, MAX_PATH, &iIndex, &uFlags);
626
627 if (uFlags & GIL_NOTFILENAME)
628 ret = FALSE;
629 else
630 {
631 lstrcpyW (psfi->szDisplayName, szLocation);
632 psfi->iIcon = iIndex;
633 }
634 IExtractIconW_Release(pei);
635 }
636 }
637 }
638
639 /* get icon index (or load icon)*/
640 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
641 {
642 if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
643 {
644 WCHAR sTemp [MAX_PATH];
645 WCHAR * szExt;
646 int icon_idx=0;
647
648 lstrcpynW(sTemp, szFullPath, MAX_PATH);
649
650 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
651 psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER, 0);
652 else
653 {
654 static const WCHAR p1W[] = {'%','1',0};
655
656 psfi->iIcon = 0;
657 szExt = PathFindExtensionW(sTemp);
658 if ( szExt &&
659 HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
660 HCR_GetIconW(sTemp, sTemp, NULL, MAX_PATH, &icon_idx))
661 {
662 if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */
663 strcpyW(sTemp, szFullPath);
664
665 if (flags & SHGFI_SYSICONINDEX)
666 {
667 psfi->iIcon = SIC_GetIconIndex(sTemp,icon_idx,0);
668 if (psfi->iIcon == -1)
669 psfi->iIcon = 0;
670 }
671 else
672 {
673 UINT ret;
674 if (flags & SHGFI_SMALLICON)
675 ret = PrivateExtractIconsW( sTemp,icon_idx,
676 GetSystemMetrics( SM_CXSMICON ),
677 GetSystemMetrics( SM_CYSMICON ),
678 &psfi->hIcon, 0, 1, 0);
679 else
680 ret = PrivateExtractIconsW( sTemp, icon_idx,
681 GetSystemMetrics( SM_CXICON),
682 GetSystemMetrics( SM_CYICON),
683 &psfi->hIcon, 0, 1, 0);
684 if (ret != 0 && ret != (UINT)-1)
685 {
686 IconNotYetLoaded=FALSE;
687 psfi->iIcon = icon_idx;
688 }
689 }
690 }
691 }
692 }
693 else
694 {
695 if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON),
696 uGilFlags, &(psfi->iIcon))))
697 {
698 ret = FALSE;
699 }
700 }
701 if (ret && (flags & SHGFI_SYSICONINDEX))
702 {
703 if (flags & SHGFI_SMALLICON)
704 ret = (DWORD_PTR) ShellSmallIconList;
705 else
706 ret = (DWORD_PTR) ShellBigIconList;
707 }
708 }
709
710 /* icon handle */
711 if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
712 {
713 if (flags & SHGFI_SMALLICON)
714 psfi->hIcon = ImageList_GetIcon( ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
715 else
716 psfi->hIcon = ImageList_GetIcon( ShellBigIconList, psfi->iIcon, ILD_NORMAL);
717 }
718
719 if (flags & ~SHGFI_KNOWN_FLAGS)
720 FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS);
721
722 if (hr != S_OK)
723 ret = FALSE;
724
725 SHFree(pidlLast);
726
727 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
728 psfi->hIcon, psfi->iIcon, psfi->dwAttributes,
729 debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret);
730
731 return ret;
732 }
733
734 /*************************************************************************
735 * SHGetFileInfoA [SHELL32.@]
736 *
737 * Note:
738 * MSVBVM60.__vbaNew2 expects this function to return a value in range
739 * 1 .. 0x7fff when the function succeeds and flags does not contain
740 * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
741 */
742 DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
743 SHFILEINFOA *psfi, UINT sizeofpsfi,
744 UINT flags )
745 {
746 INT len;
747 LPWSTR temppath = NULL;
748 LPCWSTR pathW;
749 DWORD_PTR ret;
750 SHFILEINFOW temppsfi;
751
752 if (flags & SHGFI_PIDL)
753 {
754 /* path contains a pidl */
755 pathW = (LPCWSTR)path;
756 }
757 else
758 {
759 len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
760 temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
761 MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
762 pathW = temppath;
763 }
764
765 if (psfi && (flags & SHGFI_ATTR_SPECIFIED))
766 temppsfi.dwAttributes=psfi->dwAttributes;
767
768 if (psfi == NULL)
769 ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, 0, flags);
770 else
771 ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
772
773 if (psfi)
774 {
775 if(flags & SHGFI_ICON)
776 psfi->hIcon=temppsfi.hIcon;
777 if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
778 psfi->iIcon=temppsfi.iIcon;
779 if(flags & SHGFI_ATTRIBUTES)
780 psfi->dwAttributes=temppsfi.dwAttributes;
781 if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
782 {
783 WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1,
784 psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
785 }
786 if(flags & SHGFI_TYPENAME)
787 {
788 WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1,
789 psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
790 }
791 }
792
793 HeapFree(GetProcessHeap(), 0, temppath);
794
795 return ret;
796 }
797
798 /*************************************************************************
799 * DuplicateIcon [SHELL32.@]
800 */
801 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
802 {
803 ICONINFO IconInfo;
804 HICON hDupIcon = 0;
805
806 TRACE("%p %p\n", hInstance, hIcon);
807
808 if (GetIconInfo(hIcon, &IconInfo))
809 {
810 hDupIcon = CreateIconIndirect(&IconInfo);
811
812 /* clean up hbmMask and hbmColor */
813 DeleteObject(IconInfo.hbmMask);
814 DeleteObject(IconInfo.hbmColor);
815 }
816
817 return hDupIcon;
818 }
819
820 /*************************************************************************
821 * ExtractIconA [SHELL32.@]
822 */
823 HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex)
824 {
825 HICON ret;
826 INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
827 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
828
829 TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex);
830
831 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
832 ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex);
833 HeapFree(GetProcessHeap(), 0, lpwstrFile);
834
835 return ret;
836 }
837
838 /*************************************************************************
839 * ExtractIconW [SHELL32.@]
840 */
841 HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
842 {
843 HICON hIcon = NULL;
844 UINT ret;
845 UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON);
846
847 TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex);
848
849 if (nIconIndex == (UINT)-1)
850 {
851 ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR);
852 if (ret != (UINT)-1 && ret)
853 return (HICON)(UINT_PTR)ret;
854 return NULL;
855 }
856 else
857 ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR);
858
859 if (ret == (UINT)-1)
860 return (HICON)1;
861 else if (ret > 0 && hIcon)
862 return hIcon;
863
864 return NULL;
865 }
866
867 /*************************************************************************
868 * Printer_LoadIconsW [SHELL32.205]
869 */
870 VOID WINAPI Printer_LoadIconsW(LPCWSTR wsPrinterName, HICON * pLargeIcon, HICON * pSmallIcon)
871 {
872 INT iconindex=IDI_SHELL_PRINTERS_FOLDER;
873
874 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName), pLargeIcon, pSmallIcon);
875
876 /* We should check if wsPrinterName is
877 1. the Default Printer or not
878 2. connected or not
879 3. a Local Printer or a Network-Printer
880 and use different Icons
881 */
882 if((wsPrinterName != NULL) && (wsPrinterName[0] != 0))
883 {
884 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName));
885 }
886
887 if(pLargeIcon != NULL)
888 *pLargeIcon = LoadImageW(shell32_hInstance,
889 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
890 0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE);
891
892 if(pSmallIcon != NULL)
893 *pSmallIcon = LoadImageW(shell32_hInstance,
894 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
895 16, 16, LR_DEFAULTCOLOR);
896 }
897
898 /*************************************************************************
899 * Printers_RegisterWindowW [SHELL32.213]
900 * used by "printui.dll":
901 * find the Window of the given Type for the specific Printer and
902 * return the already existent hwnd or open a new window
903 */
904 BOOL WINAPI Printers_RegisterWindowW(LPCWSTR wsPrinter, DWORD dwType,
905 HANDLE * phClassPidl, HWND * phwnd)
906 {
907 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter), dwType,
908 phClassPidl, (phClassPidl != NULL) ? *(phClassPidl) : NULL,
909 phwnd, (phwnd != NULL) ? *(phwnd) : NULL);
910
911 return FALSE;
912 }
913
914 /*************************************************************************
915 * Printers_UnregisterWindow [SHELL32.214]
916 */
917 VOID WINAPI Printers_UnregisterWindow(HANDLE hClassPidl, HWND hwnd)
918 {
919 FIXME("(%p, %p) stub!\n", hClassPidl, hwnd);
920 }
921
922 /*************************************************************************/
923
924 typedef struct
925 {
926 LPCWSTR szApp;
927 LPCWSTR szOtherStuff;
928 HICON hIcon;
929 } ABOUT_INFO;
930
931 #define DROP_FIELD_TOP (-15)
932 #define DROP_FIELD_HEIGHT 15
933
934 /*************************************************************************
935 * SHAppBarMessage [SHELL32.@]
936 */
937 UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
938 {
939 int width=data->rc.right - data->rc.left;
940 int height=data->rc.bottom - data->rc.top;
941 RECT rec=data->rc;
942
943 TRACE("msg=%d, data={cb=%d, hwnd=%p, callback=%x, edge=%d, rc=%s, lparam=%lx}\n",
944 msg, data->cbSize, data->hWnd, data->uCallbackMessage, data->uEdge,
945 wine_dbgstr_rect(&data->rc), data->lParam);
946
947 switch (msg)
948 {
949 case ABM_GETSTATE:
950 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
951
952 case ABM_GETTASKBARPOS:
953 GetWindowRect(data->hWnd, &rec);
954 data->rc=rec;
955 return TRUE;
956
957 case ABM_ACTIVATE:
958 SetActiveWindow(data->hWnd);
959 return TRUE;
960
961 case ABM_GETAUTOHIDEBAR:
962 return 0; /* pretend there is no autohide bar */
963
964 case ABM_NEW:
965 /* cbSize, hWnd, and uCallbackMessage are used. All other ignored */
966 SetWindowPos(data->hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
967 return TRUE;
968
969 case ABM_QUERYPOS:
970 GetWindowRect(data->hWnd, &(data->rc));
971 return TRUE;
972
973 case ABM_REMOVE:
974 FIXME("ABM_REMOVE broken\n");
975 /* FIXME: this is wrong; should it be DestroyWindow instead? */
976 /*CloseHandle(data->hWnd);*/
977 return TRUE;
978
979 case ABM_SETAUTOHIDEBAR:
980 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
981 width,height,SWP_SHOWWINDOW);
982 return TRUE;
983
984 case ABM_SETPOS:
985 data->uEdge=(ABE_RIGHT | ABE_LEFT);
986 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
987 width,height,SWP_SHOWWINDOW);
988 return TRUE;
989
990 case ABM_WINDOWPOSCHANGED:
991 return TRUE;
992 }
993
994 return FALSE;
995 }
996
997 /*************************************************************************
998 * SHHelpShortcuts_RunDLLA [SHELL32.@]
999 *
1000 */
1001 DWORD WINAPI SHHelpShortcuts_RunDLLA(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
1002 {
1003 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
1004 return 0;
1005 }
1006
1007 /*************************************************************************
1008 * SHHelpShortcuts_RunDLLA [SHELL32.@]
1009 *
1010 */
1011 DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
1012 {
1013 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
1014 return 0;
1015 }
1016
1017 /*************************************************************************
1018 * SHLoadInProc [SHELL32.@]
1019 * Create an instance of specified object class from within
1020 * the shell process and release it immediately
1021 */
1022 HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
1023 {
1024 void *ptr = NULL;
1025
1026 TRACE("%s\n", debugstr_guid(rclsid));
1027
1028 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
1029 if (ptr)
1030 return S_OK;
1031 return DISP_E_MEMBERNOTFOUND;
1032 }
1033
1034 static VOID SetRegTextData(HWND hWnd, HKEY hKey, LPCWSTR Value, UINT uID)
1035 {
1036 DWORD dwBufferSize;
1037 DWORD dwType;
1038 LPWSTR lpBuffer;
1039
1040 if( RegQueryValueExW(hKey, Value, NULL, &dwType, NULL, &dwBufferSize) == ERROR_SUCCESS )
1041 {
1042 if(dwType == REG_SZ)
1043 {
1044 lpBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwBufferSize);
1045
1046 if(lpBuffer)
1047 {
1048 if( RegQueryValueExW(hKey, Value, NULL, &dwType, (LPBYTE)lpBuffer, &dwBufferSize) == ERROR_SUCCESS )
1049 {
1050 SetDlgItemTextW(hWnd, uID, lpBuffer);
1051 }
1052
1053 HeapFree(GetProcessHeap(), 0, lpBuffer);
1054 }
1055 }
1056 }
1057 }
1058
1059 INT_PTR CALLBACK AboutAuthorsDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
1060 {
1061 switch(msg)
1062 {
1063 case WM_INITDIALOG:
1064 {
1065 const char* const *pstr = SHELL_Authors;
1066
1067 // Add the authors to the list
1068 SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, WM_SETREDRAW, FALSE, 0 );
1069
1070 while (*pstr)
1071 {
1072 WCHAR name[64];
1073
1074 /* authors list is in utf-8 format */
1075 MultiByteToWideChar( CP_UTF8, 0, *pstr, -1, name, sizeof(name)/sizeof(WCHAR) );
1076 SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, LB_ADDSTRING, (WPARAM)-1, (LPARAM)name );
1077 pstr++;
1078 }
1079
1080 SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, WM_SETREDRAW, TRUE, 0 );
1081
1082 return TRUE;
1083 }
1084 }
1085
1086 return FALSE;
1087 }
1088 /*************************************************************************
1089 * AboutDlgProc (internal)
1090 */
1091 static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
1092 {
1093 static DWORD cxLogoBmp;
1094 static DWORD cyLogoBmp;
1095 static HBITMAP hLogoBmp;
1096 static HWND hWndAuthors;
1097
1098 switch(msg)
1099 {
1100 case WM_INITDIALOG:
1101 {
1102 ABOUT_INFO *info = (ABOUT_INFO *)lParam;
1103
1104 if (info)
1105 {
1106 const WCHAR szRegKey[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
1107 HKEY hRegKey;
1108 MEMORYSTATUSEX MemStat;
1109 WCHAR szAppTitle[512];
1110 WCHAR szAppTitleTemplate[512];
1111 WCHAR szAuthorsText[20];
1112
1113 // Preload the ROS bitmap
1114 hLogoBmp = (HBITMAP)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IDB_REACTOS), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
1115
1116 if(hLogoBmp)
1117 {
1118 BITMAP bmpLogo;
1119
1120 GetObject( hLogoBmp, sizeof(BITMAP), &bmpLogo );
1121
1122 cxLogoBmp = bmpLogo.bmWidth;
1123 cyLogoBmp = bmpLogo.bmHeight;
1124 }
1125
1126 // Set App-specific stuff (icon, app name, szOtherStuff string)
1127 SendDlgItemMessageW(hWnd, IDC_ABOUT_ICON, STM_SETICON, (WPARAM)info->hIcon, 0);
1128
1129 GetWindowTextW( hWnd, szAppTitleTemplate, sizeof(szAppTitleTemplate) / sizeof(WCHAR) );
1130 swprintf( szAppTitle, szAppTitleTemplate, info->szApp );
1131 SetWindowTextW( hWnd, szAppTitle );
1132
1133 SetDlgItemTextW( hWnd, IDC_ABOUT_APPNAME, info->szApp );
1134 SetDlgItemTextW( hWnd, IDC_ABOUT_OTHERSTUFF, info->szOtherStuff );
1135
1136 // Set the registered user and organization name
1137 if(RegOpenKeyExW( HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_QUERY_VALUE, &hRegKey ) == ERROR_SUCCESS)
1138 {
1139 SetRegTextData( hWnd, hRegKey, L"RegisteredOwner", IDC_ABOUT_REG_USERNAME );
1140 SetRegTextData( hWnd, hRegKey, L"RegisteredOrganization", IDC_ABOUT_REG_ORGNAME );
1141
1142 RegCloseKey( hRegKey );
1143 }
1144
1145 // Set the value for the installed physical memory
1146 MemStat.dwLength = sizeof(MemStat);
1147 if( GlobalMemoryStatusEx(&MemStat) )
1148 {
1149 WCHAR szBuf[12];
1150
1151 if (MemStat.ullTotalPhys > 1024 * 1024 * 1024)
1152 {
1153 double dTotalPhys;
1154 WCHAR szDecimalSeparator[4];
1155 WCHAR szUnits[3];
1156
1157 // We're dealing with GBs or more
1158 MemStat.ullTotalPhys /= 1024 * 1024;
1159
1160 if (MemStat.ullTotalPhys > 1024 * 1024)
1161 {
1162 // We're dealing with TBs or more
1163 MemStat.ullTotalPhys /= 1024;
1164
1165 if (MemStat.ullTotalPhys > 1024 * 1024)
1166 {
1167 // We're dealing with PBs or more
1168 MemStat.ullTotalPhys /= 1024;
1169
1170 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1171 wcscpy( szUnits, L"PB" );
1172 }
1173 else
1174 {
1175 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1176 wcscpy( szUnits, L"TB" );
1177 }
1178 }
1179 else
1180 {
1181 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1182 wcscpy( szUnits, L"GB" );
1183 }
1184
1185 // We need the decimal point of the current locale to display the RAM size correctly
1186 if (GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL,
1187 szDecimalSeparator,
1188 sizeof(szDecimalSeparator) / sizeof(WCHAR)) > 0)
1189 {
1190 UCHAR uDecimals;
1191 UINT uIntegral;
1192
1193 uIntegral = (UINT)dTotalPhys;
1194 uDecimals = (UCHAR)((UINT)(dTotalPhys * 100) - uIntegral * 100);
1195
1196 // Display the RAM size with 2 decimals
1197 swprintf(szBuf, L"%u%s%02u %s", uIntegral, szDecimalSeparator, uDecimals, szUnits);
1198 }
1199 }
1200 else
1201 {
1202 // We're dealing with MBs, don't show any decimals
1203 swprintf( szBuf, L"%u MB", (UINT)MemStat.ullTotalPhys / 1024 / 1024 );
1204 }
1205
1206 SetDlgItemTextW( hWnd, IDC_ABOUT_PHYSMEM, szBuf);
1207 }
1208
1209 // Add the Authors dialog
1210 hWndAuthors = CreateDialogW( shell32_hInstance, MAKEINTRESOURCEW(IDD_ABOUT_AUTHORS), hWnd, AboutAuthorsDlgProc );
1211 LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_AUTHORS, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1212 SetDlgItemTextW( hWnd, IDC_ABOUT_AUTHORS, szAuthorsText );
1213 }
1214
1215 return TRUE;
1216 }
1217
1218 case WM_PAINT:
1219 {
1220 if(hLogoBmp)
1221 {
1222 PAINTSTRUCT ps;
1223 HDC hdc;
1224 HDC hdcMem;
1225
1226 hdc = BeginPaint(hWnd, &ps);
1227 hdcMem = CreateCompatibleDC(hdc);
1228
1229 if(hdcMem)
1230 {
1231 SelectObject(hdcMem, hLogoBmp);
1232 BitBlt(hdc, 0, 0, cxLogoBmp, cyLogoBmp, hdcMem, 0, 0, SRCCOPY);
1233
1234 DeleteDC(hdcMem);
1235 }
1236
1237 EndPaint(hWnd, &ps);
1238 }
1239 }; break;
1240
1241 case WM_COMMAND:
1242 {
1243 switch(wParam)
1244 {
1245 case IDOK:
1246 case IDCANCEL:
1247 EndDialog(hWnd, TRUE);
1248 return TRUE;
1249
1250 case IDC_ABOUT_AUTHORS:
1251 {
1252 static BOOL bShowingAuthors = FALSE;
1253 WCHAR szAuthorsText[20];
1254
1255 if(bShowingAuthors)
1256 {
1257 LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_AUTHORS, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1258 ShowWindow( hWndAuthors, SW_HIDE );
1259 }
1260 else
1261 {
1262 LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_BACK, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1263 ShowWindow( hWndAuthors, SW_SHOW );
1264 }
1265
1266 SetDlgItemTextW( hWnd, IDC_ABOUT_AUTHORS, szAuthorsText );
1267 bShowingAuthors = !bShowingAuthors;
1268 return TRUE;
1269 }
1270 }
1271 }; break;
1272
1273 case WM_CLOSE:
1274 EndDialog(hWnd, TRUE);
1275 break;
1276 }
1277
1278 return 0;
1279 }
1280
1281
1282 /*************************************************************************
1283 * ShellAboutA [SHELL32.288]
1284 */
1285 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon )
1286 {
1287 BOOL ret;
1288 LPWSTR appW = NULL, otherW = NULL;
1289 int len;
1290
1291 if (szApp)
1292 {
1293 len = MultiByteToWideChar(CP_ACP, 0, szApp, -1, NULL, 0);
1294 appW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1295 MultiByteToWideChar(CP_ACP, 0, szApp, -1, appW, len);
1296 }
1297 if (szOtherStuff)
1298 {
1299 len = MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, NULL, 0);
1300 otherW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1301 MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, otherW, len);
1302 }
1303
1304 ret = ShellAboutW(hWnd, appW, otherW, hIcon);
1305
1306 HeapFree(GetProcessHeap(), 0, otherW);
1307 HeapFree(GetProcessHeap(), 0, appW);
1308 return ret;
1309 }
1310
1311
1312 /*************************************************************************
1313 * ShellAboutW [SHELL32.289]
1314 */
1315 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
1316 HICON hIcon )
1317 {
1318 ABOUT_INFO info;
1319 HRSRC hRes;
1320 DLGTEMPLATE *DlgTemplate;
1321 BOOL bRet;
1322
1323 TRACE("\n");
1324
1325 // DialogBoxIndirectParamW will be called with the hInstance of the calling application, so we have to preload the dialog template
1326 hRes = FindResourceW(shell32_hInstance, MAKEINTRESOURCEW(IDD_ABOUT), (LPWSTR)RT_DIALOG);
1327 if(!hRes)
1328 return FALSE;
1329
1330 DlgTemplate = (DLGTEMPLATE *)LoadResource(shell32_hInstance, hRes);
1331 if(!DlgTemplate)
1332 return FALSE;
1333
1334 info.szApp = szApp;
1335 info.szOtherStuff = szOtherStuff;
1336 info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
1337
1338 bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ),
1339 DlgTemplate, hWnd, AboutDlgProc, (LPARAM)&info );
1340 return bRet;
1341 }
1342
1343 /*************************************************************************
1344 * FreeIconList (SHELL32.@)
1345 */
1346 void WINAPI FreeIconList( DWORD dw )
1347 {
1348 FIXME("%x: stub\n",dw);
1349 }
1350
1351 /*************************************************************************
1352 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1353 */
1354 HRESULT WINAPI SHLoadNonloadedIconOverlayIdentifiers( VOID )
1355 {
1356 FIXME("stub\n");
1357 return S_OK;
1358 }