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