[SHELL32]
[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 (psfParent)
727 IShellFolder_Release(psfParent);
728
729 if (hr != S_OK)
730 ret = FALSE;
731
732 SHFree(pidlLast);
733
734 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
735 psfi->hIcon, psfi->iIcon, psfi->dwAttributes,
736 debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret);
737
738 return ret;
739 }
740
741 /*************************************************************************
742 * SHGetFileInfoA [SHELL32.@]
743 *
744 * Note:
745 * MSVBVM60.__vbaNew2 expects this function to return a value in range
746 * 1 .. 0x7fff when the function succeeds and flags does not contain
747 * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
748 */
749 DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
750 SHFILEINFOA *psfi, UINT sizeofpsfi,
751 UINT flags )
752 {
753 INT len;
754 LPWSTR temppath = NULL;
755 LPCWSTR pathW;
756 DWORD_PTR ret;
757 SHFILEINFOW temppsfi;
758
759 if (flags & SHGFI_PIDL)
760 {
761 /* path contains a pidl */
762 pathW = (LPCWSTR)path;
763 }
764 else
765 {
766 len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
767 temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
768 MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
769 pathW = temppath;
770 }
771
772 if (psfi && (flags & SHGFI_ATTR_SPECIFIED))
773 temppsfi.dwAttributes=psfi->dwAttributes;
774
775 if (psfi == NULL)
776 ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, 0, flags);
777 else
778 ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
779
780 if (psfi)
781 {
782 if(flags & SHGFI_ICON)
783 psfi->hIcon=temppsfi.hIcon;
784 if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
785 psfi->iIcon=temppsfi.iIcon;
786 if(flags & SHGFI_ATTRIBUTES)
787 psfi->dwAttributes=temppsfi.dwAttributes;
788 if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
789 {
790 WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1,
791 psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
792 }
793 if(flags & SHGFI_TYPENAME)
794 {
795 WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1,
796 psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
797 }
798 }
799
800 HeapFree(GetProcessHeap(), 0, temppath);
801
802 return ret;
803 }
804
805 /*************************************************************************
806 * DuplicateIcon [SHELL32.@]
807 */
808 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
809 {
810 ICONINFO IconInfo;
811 HICON hDupIcon = 0;
812
813 TRACE("%p %p\n", hInstance, hIcon);
814
815 if (GetIconInfo(hIcon, &IconInfo))
816 {
817 hDupIcon = CreateIconIndirect(&IconInfo);
818
819 /* clean up hbmMask and hbmColor */
820 DeleteObject(IconInfo.hbmMask);
821 DeleteObject(IconInfo.hbmColor);
822 }
823
824 return hDupIcon;
825 }
826
827 /*************************************************************************
828 * ExtractIconA [SHELL32.@]
829 */
830 HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex)
831 {
832 HICON ret;
833 INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
834 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
835
836 TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex);
837
838 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
839 ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex);
840 HeapFree(GetProcessHeap(), 0, lpwstrFile);
841
842 return ret;
843 }
844
845 /*************************************************************************
846 * ExtractIconW [SHELL32.@]
847 */
848 HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
849 {
850 HICON hIcon = NULL;
851 UINT ret;
852 UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON);
853
854 TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex);
855
856 if (nIconIndex == (UINT)-1)
857 {
858 ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR);
859 if (ret != (UINT)-1 && ret)
860 return (HICON)(UINT_PTR)ret;
861 return NULL;
862 }
863 else
864 ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR);
865
866 if (ret == (UINT)-1)
867 return (HICON)1;
868 else if (ret > 0 && hIcon)
869 return hIcon;
870
871 return NULL;
872 }
873
874 /*************************************************************************
875 * Printer_LoadIconsW [SHELL32.205]
876 */
877 VOID WINAPI Printer_LoadIconsW(LPCWSTR wsPrinterName, HICON * pLargeIcon, HICON * pSmallIcon)
878 {
879 INT iconindex=IDI_SHELL_PRINTERS_FOLDER;
880
881 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName), pLargeIcon, pSmallIcon);
882
883 /* We should check if wsPrinterName is
884 1. the Default Printer or not
885 2. connected or not
886 3. a Local Printer or a Network-Printer
887 and use different Icons
888 */
889 if((wsPrinterName != NULL) && (wsPrinterName[0] != 0))
890 {
891 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName));
892 }
893
894 if(pLargeIcon != NULL)
895 *pLargeIcon = LoadImageW(shell32_hInstance,
896 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
897 0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE);
898
899 if(pSmallIcon != NULL)
900 *pSmallIcon = LoadImageW(shell32_hInstance,
901 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
902 16, 16, LR_DEFAULTCOLOR);
903 }
904
905 /*************************************************************************
906 * Printers_RegisterWindowW [SHELL32.213]
907 * used by "printui.dll":
908 * find the Window of the given Type for the specific Printer and
909 * return the already existent hwnd or open a new window
910 */
911 BOOL WINAPI Printers_RegisterWindowW(LPCWSTR wsPrinter, DWORD dwType,
912 HANDLE * phClassPidl, HWND * phwnd)
913 {
914 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter), dwType,
915 phClassPidl, (phClassPidl != NULL) ? *(phClassPidl) : NULL,
916 phwnd, (phwnd != NULL) ? *(phwnd) : NULL);
917
918 return FALSE;
919 }
920
921 /*************************************************************************
922 * Printers_UnregisterWindow [SHELL32.214]
923 */
924 VOID WINAPI Printers_UnregisterWindow(HANDLE hClassPidl, HWND hwnd)
925 {
926 FIXME("(%p, %p) stub!\n", hClassPidl, hwnd);
927 }
928
929 /*************************************************************************/
930
931 typedef struct
932 {
933 LPCWSTR szApp;
934 LPCWSTR szOtherStuff;
935 HICON hIcon;
936 } ABOUT_INFO;
937
938 #define DROP_FIELD_TOP (-15)
939 #define DROP_FIELD_HEIGHT 15
940
941 /*************************************************************************
942 * SHAppBarMessage [SHELL32.@]
943 */
944 UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
945 {
946 int width=data->rc.right - data->rc.left;
947 int height=data->rc.bottom - data->rc.top;
948 RECT rec=data->rc;
949
950 TRACE("msg=%d, data={cb=%d, hwnd=%p, callback=%x, edge=%d, rc=%s, lparam=%lx}\n",
951 msg, data->cbSize, data->hWnd, data->uCallbackMessage, data->uEdge,
952 wine_dbgstr_rect(&data->rc), data->lParam);
953
954 switch (msg)
955 {
956 case ABM_GETSTATE:
957 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
958
959 case ABM_GETTASKBARPOS:
960 GetWindowRect(data->hWnd, &rec);
961 data->rc=rec;
962 return TRUE;
963
964 case ABM_ACTIVATE:
965 SetActiveWindow(data->hWnd);
966 return TRUE;
967
968 case ABM_GETAUTOHIDEBAR:
969 return 0; /* pretend there is no autohide bar */
970
971 case ABM_NEW:
972 /* cbSize, hWnd, and uCallbackMessage are used. All other ignored */
973 SetWindowPos(data->hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
974 return TRUE;
975
976 case ABM_QUERYPOS:
977 GetWindowRect(data->hWnd, &(data->rc));
978 return TRUE;
979
980 case ABM_REMOVE:
981 FIXME("ABM_REMOVE broken\n");
982 /* FIXME: this is wrong; should it be DestroyWindow instead? */
983 /*CloseHandle(data->hWnd);*/
984 return TRUE;
985
986 case ABM_SETAUTOHIDEBAR:
987 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
988 width,height,SWP_SHOWWINDOW);
989 return TRUE;
990
991 case ABM_SETPOS:
992 data->uEdge=(ABE_RIGHT | ABE_LEFT);
993 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
994 width,height,SWP_SHOWWINDOW);
995 return TRUE;
996
997 case ABM_WINDOWPOSCHANGED:
998 return TRUE;
999 }
1000
1001 return FALSE;
1002 }
1003
1004 /*************************************************************************
1005 * SHHelpShortcuts_RunDLLA [SHELL32.@]
1006 *
1007 */
1008 DWORD WINAPI SHHelpShortcuts_RunDLLA(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
1009 {
1010 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
1011 return 0;
1012 }
1013
1014 /*************************************************************************
1015 * SHHelpShortcuts_RunDLLA [SHELL32.@]
1016 *
1017 */
1018 DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
1019 {
1020 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
1021 return 0;
1022 }
1023
1024 /*************************************************************************
1025 * SHLoadInProc [SHELL32.@]
1026 * Create an instance of specified object class from within
1027 * the shell process and release it immediately
1028 */
1029 HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
1030 {
1031 void *ptr = NULL;
1032
1033 TRACE("%s\n", debugstr_guid(rclsid));
1034
1035 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
1036 if(ptr)
1037 {
1038 IUnknown * pUnk = ptr;
1039 IUnknown_Release(pUnk);
1040 return S_OK;
1041 }
1042 return DISP_E_MEMBERNOTFOUND;
1043 }
1044
1045 static VOID SetRegTextData(HWND hWnd, HKEY hKey, LPCWSTR Value, UINT uID)
1046 {
1047 DWORD dwBufferSize;
1048 DWORD dwType;
1049 LPWSTR lpBuffer;
1050
1051 if( RegQueryValueExW(hKey, Value, NULL, &dwType, NULL, &dwBufferSize) == ERROR_SUCCESS )
1052 {
1053 if(dwType == REG_SZ)
1054 {
1055 lpBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwBufferSize);
1056
1057 if(lpBuffer)
1058 {
1059 if( RegQueryValueExW(hKey, Value, NULL, &dwType, (LPBYTE)lpBuffer, &dwBufferSize) == ERROR_SUCCESS )
1060 {
1061 SetDlgItemTextW(hWnd, uID, lpBuffer);
1062 }
1063
1064 HeapFree(GetProcessHeap(), 0, lpBuffer);
1065 }
1066 }
1067 }
1068 }
1069
1070 INT_PTR CALLBACK AboutAuthorsDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
1071 {
1072 switch(msg)
1073 {
1074 case WM_INITDIALOG:
1075 {
1076 const char* const *pstr = SHELL_Authors;
1077
1078 // Add the authors to the list
1079 SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, WM_SETREDRAW, FALSE, 0 );
1080
1081 while (*pstr)
1082 {
1083 WCHAR name[64];
1084
1085 /* authors list is in utf-8 format */
1086 MultiByteToWideChar( CP_UTF8, 0, *pstr, -1, name, sizeof(name)/sizeof(WCHAR) );
1087 SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, LB_ADDSTRING, (WPARAM)-1, (LPARAM)name );
1088 pstr++;
1089 }
1090
1091 SendDlgItemMessageW( hWnd, IDC_ABOUT_AUTHORS_LISTBOX, WM_SETREDRAW, TRUE, 0 );
1092
1093 return TRUE;
1094 }
1095 }
1096
1097 return FALSE;
1098 }
1099 /*************************************************************************
1100 * AboutDlgProc (internal)
1101 */
1102 static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
1103 {
1104 static DWORD cxLogoBmp;
1105 static DWORD cyLogoBmp;
1106 static HBITMAP hLogoBmp;
1107 static HWND hWndAuthors;
1108
1109 switch(msg)
1110 {
1111 case WM_INITDIALOG:
1112 {
1113 ABOUT_INFO *info = (ABOUT_INFO *)lParam;
1114
1115 if (info)
1116 {
1117 const WCHAR szRegKey[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
1118 HKEY hRegKey;
1119 MEMORYSTATUSEX MemStat;
1120 WCHAR szAppTitle[512];
1121 WCHAR szAppTitleTemplate[512];
1122 WCHAR szAuthorsText[20];
1123
1124 // Preload the ROS bitmap
1125 hLogoBmp = (HBITMAP)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IDB_REACTOS), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
1126
1127 if(hLogoBmp)
1128 {
1129 BITMAP bmpLogo;
1130
1131 GetObject( hLogoBmp, sizeof(BITMAP), &bmpLogo );
1132
1133 cxLogoBmp = bmpLogo.bmWidth;
1134 cyLogoBmp = bmpLogo.bmHeight;
1135 }
1136
1137 // Set App-specific stuff (icon, app name, szOtherStuff string)
1138 SendDlgItemMessageW(hWnd, IDC_ABOUT_ICON, STM_SETICON, (WPARAM)info->hIcon, 0);
1139
1140 GetWindowTextW( hWnd, szAppTitleTemplate, sizeof(szAppTitleTemplate) / sizeof(WCHAR) );
1141 swprintf( szAppTitle, szAppTitleTemplate, info->szApp );
1142 SetWindowTextW( hWnd, szAppTitle );
1143
1144 SetDlgItemTextW( hWnd, IDC_ABOUT_APPNAME, info->szApp );
1145 SetDlgItemTextW( hWnd, IDC_ABOUT_OTHERSTUFF, info->szOtherStuff );
1146
1147 // Set the registered user and organization name
1148 if(RegOpenKeyExW( HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_QUERY_VALUE, &hRegKey ) == ERROR_SUCCESS)
1149 {
1150 SetRegTextData( hWnd, hRegKey, L"RegisteredOwner", IDC_ABOUT_REG_USERNAME );
1151 SetRegTextData( hWnd, hRegKey, L"RegisteredOrganization", IDC_ABOUT_REG_ORGNAME );
1152
1153 RegCloseKey( hRegKey );
1154 }
1155
1156 // Set the value for the installed physical memory
1157 MemStat.dwLength = sizeof(MemStat);
1158 if( GlobalMemoryStatusEx(&MemStat) )
1159 {
1160 WCHAR szBuf[12];
1161
1162 if (MemStat.ullTotalPhys > 1024 * 1024 * 1024)
1163 {
1164 double dTotalPhys;
1165 WCHAR szDecimalSeparator[4];
1166 WCHAR szUnits[3];
1167
1168 // We're dealing with GBs or more
1169 MemStat.ullTotalPhys /= 1024 * 1024;
1170
1171 if (MemStat.ullTotalPhys > 1024 * 1024)
1172 {
1173 // We're dealing with TBs or more
1174 MemStat.ullTotalPhys /= 1024;
1175
1176 if (MemStat.ullTotalPhys > 1024 * 1024)
1177 {
1178 // We're dealing with PBs or more
1179 MemStat.ullTotalPhys /= 1024;
1180
1181 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1182 wcscpy( szUnits, L"PB" );
1183 }
1184 else
1185 {
1186 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1187 wcscpy( szUnits, L"TB" );
1188 }
1189 }
1190 else
1191 {
1192 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
1193 wcscpy( szUnits, L"GB" );
1194 }
1195
1196 // We need the decimal point of the current locale to display the RAM size correctly
1197 if (GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL,
1198 szDecimalSeparator,
1199 sizeof(szDecimalSeparator) / sizeof(WCHAR)) > 0)
1200 {
1201 UCHAR uDecimals;
1202 UINT uIntegral;
1203
1204 uIntegral = (UINT)dTotalPhys;
1205 uDecimals = (UCHAR)((UINT)(dTotalPhys * 100) - uIntegral * 100);
1206
1207 // Display the RAM size with 2 decimals
1208 swprintf(szBuf, L"%u%s%02u %s", uIntegral, szDecimalSeparator, uDecimals, szUnits);
1209 }
1210 }
1211 else
1212 {
1213 // We're dealing with MBs, don't show any decimals
1214 swprintf( szBuf, L"%u MB", (UINT)MemStat.ullTotalPhys / 1024 / 1024 );
1215 }
1216
1217 SetDlgItemTextW( hWnd, IDC_ABOUT_PHYSMEM, szBuf);
1218 }
1219
1220 // Add the Authors dialog
1221 hWndAuthors = CreateDialogW( shell32_hInstance, MAKEINTRESOURCEW(IDD_ABOUT_AUTHORS), hWnd, AboutAuthorsDlgProc );
1222 LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_AUTHORS, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1223 SetDlgItemTextW( hWnd, IDC_ABOUT_AUTHORS, szAuthorsText );
1224 }
1225
1226 return TRUE;
1227 }
1228
1229 case WM_PAINT:
1230 {
1231 if(hLogoBmp)
1232 {
1233 PAINTSTRUCT ps;
1234 HDC hdc;
1235 HDC hdcMem;
1236
1237 hdc = BeginPaint(hWnd, &ps);
1238 hdcMem = CreateCompatibleDC(hdc);
1239
1240 if(hdcMem)
1241 {
1242 SelectObject(hdcMem, hLogoBmp);
1243 BitBlt(hdc, 0, 0, cxLogoBmp, cyLogoBmp, hdcMem, 0, 0, SRCCOPY);
1244
1245 DeleteDC(hdcMem);
1246 }
1247
1248 EndPaint(hWnd, &ps);
1249 }
1250 }; break;
1251
1252 case WM_COMMAND:
1253 {
1254 switch(wParam)
1255 {
1256 case IDOK:
1257 case IDCANCEL:
1258 EndDialog(hWnd, TRUE);
1259 return TRUE;
1260
1261 case IDC_ABOUT_AUTHORS:
1262 {
1263 static BOOL bShowingAuthors = FALSE;
1264 WCHAR szAuthorsText[20];
1265
1266 if(bShowingAuthors)
1267 {
1268 LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_AUTHORS, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1269 ShowWindow( hWndAuthors, SW_HIDE );
1270 }
1271 else
1272 {
1273 LoadStringW( shell32_hInstance, IDS_SHELL_ABOUT_BACK, szAuthorsText, sizeof(szAuthorsText) / sizeof(WCHAR) );
1274 ShowWindow( hWndAuthors, SW_SHOW );
1275 }
1276
1277 SetDlgItemTextW( hWnd, IDC_ABOUT_AUTHORS, szAuthorsText );
1278 bShowingAuthors = !bShowingAuthors;
1279 return TRUE;
1280 }
1281 }
1282 }; break;
1283
1284 case WM_CLOSE:
1285 EndDialog(hWnd, TRUE);
1286 break;
1287 }
1288
1289 return 0;
1290 }
1291
1292
1293 /*************************************************************************
1294 * ShellAboutA [SHELL32.288]
1295 */
1296 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon )
1297 {
1298 BOOL ret;
1299 LPWSTR appW = NULL, otherW = NULL;
1300 int len;
1301
1302 if (szApp)
1303 {
1304 len = MultiByteToWideChar(CP_ACP, 0, szApp, -1, NULL, 0);
1305 appW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1306 MultiByteToWideChar(CP_ACP, 0, szApp, -1, appW, len);
1307 }
1308 if (szOtherStuff)
1309 {
1310 len = MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, NULL, 0);
1311 otherW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1312 MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, otherW, len);
1313 }
1314
1315 ret = ShellAboutW(hWnd, appW, otherW, hIcon);
1316
1317 HeapFree(GetProcessHeap(), 0, otherW);
1318 HeapFree(GetProcessHeap(), 0, appW);
1319 return ret;
1320 }
1321
1322
1323 /*************************************************************************
1324 * ShellAboutW [SHELL32.289]
1325 */
1326 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
1327 HICON hIcon )
1328 {
1329 ABOUT_INFO info;
1330 HRSRC hRes;
1331 DLGTEMPLATE *DlgTemplate;
1332 BOOL bRet;
1333
1334 TRACE("\n");
1335
1336 // DialogBoxIndirectParamW will be called with the hInstance of the calling application, so we have to preload the dialog template
1337 hRes = FindResourceW(shell32_hInstance, MAKEINTRESOURCEW(IDD_ABOUT), (LPWSTR)RT_DIALOG);
1338 if(!hRes)
1339 return FALSE;
1340
1341 DlgTemplate = (DLGTEMPLATE *)LoadResource(shell32_hInstance, hRes);
1342 if(!DlgTemplate)
1343 return FALSE;
1344
1345 info.szApp = szApp;
1346 info.szOtherStuff = szOtherStuff;
1347 info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
1348
1349 bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ),
1350 DlgTemplate, hWnd, AboutDlgProc, (LPARAM)&info );
1351 return bRet;
1352 }
1353
1354 /*************************************************************************
1355 * FreeIconList (SHELL32.@)
1356 */
1357 void WINAPI FreeIconList( DWORD dw )
1358 {
1359 FIXME("%x: stub\n",dw);
1360 }
1361
1362 /*************************************************************************
1363 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1364 */
1365 HRESULT WINAPI SHLoadNonloadedIconOverlayIdentifiers( VOID )
1366 {
1367 FIXME("stub\n");
1368 return S_OK;
1369 }