Changeset 6481 for trunk/src/shell32/shelllink.c
- Timestamp:
- Aug 7, 2001, 11:33:44 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shell32/shelllink.c
r5618 r6481 26 26 #include "shlobj.h" 27 27 #include "wine/undocshell.h" 28 #ifndef __WIN32OS2__ 28 #ifdef __WIN32OS2__ 29 #define NO_DCDATA 30 #include <winuser32.h> 31 #include <winres.h> 32 33 #undef WARN 34 #undef TRACE 35 #ifdef DEBUG 36 #define TRACE WriteLog("SHELL32: %s", __FUNCTION__); WriteLog 37 #define WARN WriteLog("WARNING: SHELL32: %s", __FUNCTION__); WriteLog 38 #else 39 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 40 #define WARN 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 41 #endif 42 43 #else 29 44 #include "bitmaps/wine.xpm" 30 45 #endif … … 235 250 236 251 237 #ifndef __WIN32OS2__ 252 #ifdef __WIN32OS2__ 253 static BOOL SaveIconResAsOS2ICO(GRPICONDIR *pIconDir, HINSTANCE hInstance, const char *szXPMFileName) 254 { 255 FILE *fXPMFile; 256 void *lpOS2Icon; 257 DWORD ressize; 258 259 if (!(fXPMFile = fopen(szXPMFileName, "w"))) 260 return 0; 261 262 lpOS2Icon = ConvertIconGroup((void *)pIconDir, hInstance, &ressize); 263 if(lpOS2Icon) { 264 fwrite(lpOS2Icon, 1, ressize, fXPMFile); 265 free(lpOS2Icon); 266 } 267 fclose(fXPMFile); 268 return 1; 269 } 270 #else 238 271 /* Icon extraction routines 239 272 * … … 330 363 return 0; 331 364 } 365 #endif //__WIN32OS2__ 332 366 333 367 static BOOL CALLBACK EnumResNameProc(HANDLE hModule, const char *lpszType, char *lpszName, LONG lParam) … … 383 417 } 384 418 419 #ifdef __WIN32OS2__ 420 if(!SaveIconResAsOS2ICO(pIconDir, hModule, szXPMFileName)) 421 { 422 TRACE("Failed saving icon as XPM, error %ld\n", GetLastError()); 423 goto error3; 424 } 425 #else 385 426 for (i = 0; i < pIconDir->idCount; i++) 386 427 if ((pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth) > nMax) … … 413 454 goto error3; 414 455 } 415 456 #endif 416 457 FreeResource(hResData); 417 458 FreeLibrary(hModule); … … 436 477 void *pIcon; 437 478 int i; 479 #ifdef __WIN32OS2__ 480 int size; 481 #endif 438 482 439 483 if (!(fICOFile = fopen(szFileName, "r"))) 440 484 goto error1; 485 486 #ifdef __WIN32OS2__ 487 //TODO: 488 dprintf(("TODO: Icon file conversion not yet supported!!")); 489 goto error2; 490 #else 441 491 442 492 if (fread(&iconDir, sizeof (ICONDIR), 1, fICOFile) != 1) … … 466 516 goto error4; 467 517 518 #endif 468 519 free(pIcon); 469 520 free(pIconDirEntry); … … 482 533 } 483 534 535 #ifndef __WIN32OS2__ 484 536 /* get the Unix file name for a given path, allocating the string */ 485 537 inline static char *get_unix_file_name( const char *dos ) … … 504 556 return TRUE; 505 557 } 558 #endif //__WIN32OS2__ 506 559 507 560 /* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */ 508 static char *extract_icon( const char *path, int index ) 561 #ifdef __WIN32OS2__ 562 static char *extract_icon( const char *path, char *filename, int index) 563 { 564 if (ExtractFromEXEDLL( path, index, filename )) return filename; 565 if (ExtractFromICO( path, filename )) return filename; 566 return NULL; 567 } 568 #else 569 static char *extract_icon( const char *path, int index) 509 570 { 510 571 char *filename = HEAP_strdupA( GetProcessHeap(), 0, tmpnam(NULL) ); … … 515 576 return NULL; 516 577 } 517 #endif //__WIN32OS2__578 #endif 518 579 519 580 static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember) … … 529 590 BOOL bDesktop; 530 591 HKEY hkey; 592 #ifdef __WIN32OS2__ 593 char *tmp; 594 #endif 531 595 532 596 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface); … … 544 608 /* check if ShellLinker configured */ 545 609 #ifdef __WIN32OS2__ 546 return NOERROR; 610 dprintf(("IPersistFile_fnSave %ls", pszFileName)); 611 filename = link_name = NULL; 612 bDesktop = 0; 613 614 if (!WideCharToMultiByte( CP_ACP, 0, pszFileName, -1, buffer, sizeof(buffer), NULL, NULL)) 615 return ERROR_UNKNOWN; 616 GetFullPathNameA( buffer, sizeof(buff2), buff2, NULL ); 617 filename = HEAP_strdupA( GetProcessHeap(), 0, buff2 ); 618 619 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTUP, FALSE )) 620 { 621 /* ignore startup for now */ 622 if (!strncasecmp( filename, buffer, strlen(buffer) )) goto done; 623 } 624 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_DESKTOPDIRECTORY, FALSE )) 625 { 626 if (!strncasecmp( filename, buffer, strlen(buffer) )) 627 { 628 link_name = filename + strlen(buffer); 629 bDesktop = TRUE; 630 goto found; 631 } 632 } 633 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTMENU, FALSE )) 634 { 635 if (!strncasecmp( filename, buffer, strlen(buffer) )) 636 { 637 link_name = filename + strlen(buffer); 638 bDesktop = FALSE; 639 goto found; 640 } 641 } 642 goto done; 643 644 found: 645 646 icon_name = HEAP_strdupA( GetProcessHeap(), 0, filename ); 647 strupr(icon_name); 648 tmp = strstr(icon_name, ".LNK"); 649 if(!tmp) { 650 dprintf(("ERROR: Unexpected name %s", icon_name)); 651 goto done; 652 } 653 tmp[1] = 'I'; 654 tmp[2] = 'C'; 655 tmp[3] = 'O'; 656 /* extract the icon */ 657 if (!extract_icon( This->sIcoPath && strlen(This->sIcoPath) ? 658 This->sIcoPath : This->sPath, 659 icon_name, This->iIcoNdx)) goto done; 660 661 if(OSLibWinCreateObject(This->sPath, This->sArgs, This->sWorkDir, filename, 662 This->sDescription, icon_name, 663 This->iIcoNdx, bDesktop) == FALSE) 664 { 665 ret = E_ACCESSDENIED; 666 } 667 668 done: 669 if(shell_link_app) HeapFree( GetProcessHeap(), 0, shell_link_app ); 670 if(filename) HeapFree( GetProcessHeap(), 0, filename ); 671 if(icon_name) HeapFree( GetProcessHeap(), 0, icon_name ); 672 if(path_name) HeapFree( GetProcessHeap(), 0, path_name ); 673 if(work_dir) HeapFree( GetProcessHeap(), 0, work_dir ); 674 return ret; 675 547 676 #else 548 677 buffer[0] = 0;
Note:
See TracChangeset
for help on using the changeset viewer.