Ignore:
Timestamp:
Feb 24, 2003, 6:03:00 PM (23 years ago)
Author:
sandervl
Message:

Convert win32 icon file to os2 format when creating a shell link

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/shelllink.c

    r8699 r9851  
    263263
    264264#ifdef __WIN32OS2__
     265static BOOL SaveIconFileAsOS2ICO(char *szFileName, char *szXPMFileName)
     266{
     267    FILE *fXPMFile = NULL, *fICOFile = NULL;
     268    void *lpOS2Icon = NULL, *lpWinIcon = NULL;
     269    DWORD ressize, filesize;
     270    BOOL  ret = FALSE;
     271
     272    if (!(fICOFile = fopen(szFileName, "r")))
     273        goto failure;
     274    fseek(fICOFile, 0, SEEK_END);
     275    filesize = ftell(fICOFile);
     276    fseek(fICOFile, 0, SEEK_SET);
     277
     278    lpWinIcon = malloc(filesize);
     279    if(lpWinIcon == NULL) goto failure;
     280    if (fread(lpWinIcon, filesize, 1, fICOFile) != 1)
     281        goto failure;
     282
     283    if (!(fXPMFile = fopen(szXPMFileName, "wb")))
     284        goto failure;
     285
     286    lpOS2Icon = ConvertIconGroupIndirect(lpWinIcon, filesize, &ressize);
     287    if(lpOS2Icon) {
     288        fwrite(lpOS2Icon, 1, ressize, fXPMFile);
     289    }
     290    ret = TRUE;
     291
     292failure:
     293    if(fICOFile) fclose(fICOFile);
     294    if(fXPMFile) fclose(fXPMFile);
     295    if(lpWinIcon) free(lpWinIcon);
     296    if(lpOS2Icon) free(lpOS2Icon);
     297    return ret;
     298}
     299
    265300static BOOL SaveIconResAsOS2ICO(GRPICONDIR *pIconDir, HINSTANCE hInstance,
    266301                                const char *szXPMFileName)
     
    533568static int ExtractFromICO(const char *szFileName, const char *szXPMFileName)
    534569{
     570#ifdef __WIN32OS2__
     571    if(!SaveIconFileAsOS2ICO(szFileName, szXPMFileName))
     572    {
     573        TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
     574        return 0;
     575    }
     576    return 1;
     577#else
    535578    FILE *fICOFile;
    536579    ICONDIR iconDir;
     
    540583    void *pIcon;
    541584    int i;
    542 #ifdef __WIN32OS2__
    543     int size;
    544 #endif
    545585
    546586    if (!(fICOFile = fopen(szFileName, "r")))
    547587        goto error1;
    548 
    549 #ifdef __WIN32OS2__
    550      //TODO:
    551     dprintf(("TODO: Icon file conversion not yet supported!!"));
    552     goto error2;
    553 #else
    554588
    555589    if (fread(&iconDir, sizeof (ICONDIR), 1, fICOFile) != 1)
     
    579613        goto error4;
    580614
    581 #endif
    582615    free(pIcon);
    583616    free(pIconDirEntry);
     
    594627 error1:
    595628    return 0;
     629#endif
    596630}
    597631
     
    655689    HKEY hkey;
    656690#ifdef __WIN32OS2__
    657     char *tmp;
     691    char *tmp, szAppName[MAX_PATH];
    658692#endif
    659693
     
    664698    if (!pszFileName || !This->sPath)
    665699        return ERROR_UNKNOWN;
    666 
    667     /* check for .exe extension */
    668     if (!(p = strrchr( This->sPath, '.' ))) return NOERROR;
    669     if (strchr( p, '\\' ) || strchr( p, '/' )) return NOERROR;
    670     if (strcasecmp( p, ".exe" )) return NOERROR;
    671700
    672701    /* check if ShellLinker configured */
     
    723752                       icon_name, This->iIcoNdx)) goto done;
    724753
    725     if(OSLibWinCreateObject(This->sPath, This->sArgs, This->sWorkDir, filename,
     754    if(SearchPathA( NULL, This->sPath, ".exe", sizeof(szAppName), szAppName, NULL) == NULL)
     755    {
     756        ret = E_INVALIDARG;
     757        goto done;
     758    }
     759
     760    if(OSLibWinCreateObject(szAppName, This->sArgs, This->sWorkDir, filename,
    726761                            This->sDescription, icon_name,
    727762                            This->iIcoNdx, bDesktop) == FALSE)
     
    739774
    740775#else
     776
     777    /* check for .exe extension */
     778    if (!(p = strrchr( This->sPath, '.' ))) return NOERROR;
     779    if (strchr( p, '\\' ) || strchr( p, '/' )) return NOERROR;
     780    if (strcasecmp( p, ".exe" )) return NOERROR;
     781
    741782    buffer[0] = 0;
    742783    if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine",
Note: See TracChangeset for help on using the changeset viewer.