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