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