Ignore:
Timestamp:
Mar 8, 2002, 12:01:03 PM (23 years ago)
Author:
sandervl
Message:

PH: Wine resync + OS2 integration

File:
1 edited

Legend:

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

    r7508 r8048  
    118118#include "poppack.h"
    119119
     120typedef struct
     121{
     122        HRSRC *pResInfo;
     123        int   nIndex;
     124} ENUMRESSTRUCT;
    120125
    121126static ICOM_VTABLE(IShellLinkA)         slvt;
     
    162167#define _ICOM_THIS_From_IPersistStream(class, name) class* This = (class*)(((char*)name)-_IPersistStream_Offset);
    163168#define _IPersistStream_From_ICOM_THIS(class, name) class* StreamThis = (class*)(((char*)name)+_IPersistStream_Offset);
     169
     170
     171/* strdup on the process heap */
     172inline static LPSTR heap_strdup( LPCSTR str )
     173{
     174    INT len = strlen(str) + 1;
     175    LPSTR p = HeapAlloc( GetProcessHeap(), 0, len );
     176    if (p) memcpy( p, str, len );
     177    return p;
     178}
     179
    164180
    165181/**************************************************************************
     
    364380static BOOL CALLBACK EnumResNameProc(HANDLE hModule, const char *lpszType, char *lpszName, LONG lParam)
    365381{
    366     *(HRSRC *) lParam = FindResourceA(hModule, lpszName, RT_GROUP_ICONA);
    367     return FALSE;
    368 }
     382        ENUMRESSTRUCT *sEnumRes = (ENUMRESSTRUCT *) lParam;
     383   
     384        if (!sEnumRes->nIndex--)
     385        {
     386                *sEnumRes->pResInfo = FindResourceA(hModule, lpszName, RT_GROUP_ICONA);
     387                return FALSE;
     388        }
     389        else
     390                return TRUE;
     391}
     392
    369393
    370394static int ExtractFromEXEDLL(const char *szFileName, int nIndex, const char *szXPMFileName)
     
    448472#else
    449473    for (i = 0; i < pIconDir->idCount; i++)
    450         if ((pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth) > nMax)
     474        if ((pIconDir->idEntries[i].wBitCount >= nMaxBits) && (pIconDir->idEntries[i].wBitCount <= 8))
    451475        {
    452             lpName = MAKEINTRESOURCEA(pIconDir->idEntries[i].nID);
    453             nMax = pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth;
     476          if (pIconDir->idEntries[i].wBitCount > nMaxBits)
     477          {
     478              nMaxBits = pIconDir->idEntries[i].wBitCount;
     479              nMax = 0;
     480          }
     481          if ((pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth) > nMax)
     482          {
     483              lpName = MAKEINTRESOURCEA(pIconDir->idEntries[i].nID);
     484              nMax = pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth;
     485          }
    454486        }
    455487
     
    480512
    481513done:
     514
    482515    FreeResource(hResData);
    483516    FreeLibrary(hModule);
     
    565598
    566599    if (!wine_get_unix_file_name( dos, buffer, sizeof(buffer) )) return NULL;
    567     return HEAP_strdupA( GetProcessHeap(), 0, buffer );
     600    return heap_strdup( buffer );
    568601}
    569602
     
    594627static char *extract_icon( const char *path, int index)
    595628{
    596     char *filename = HEAP_strdupA( GetProcessHeap(), 0, tmpnam(NULL) );
     629    char *filename = heap_strdup( tmpnam(NULL) );
    597630    if (ExtractFromEXEDLL( path, index, filename )) return filename;
    598631    if (ExtractFromICO( path, filename )) return filename;
     
    602635}
    603636#endif
     637
    604638
    605639static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
     
    709743    }
    710744    if (!*buffer) return NOERROR;
    711     shell_link_app = HEAP_strdupA( GetProcessHeap(), 0, buffer );
     745    shell_link_app = heap_strdup( buffer );
    712746
    713747    if (!WideCharToMultiByte( CP_ACP, 0, pszFileName, -1, buffer, sizeof(buffer), NULL, NULL))
    714748        return ERROR_UNKNOWN;
    715749    GetFullPathNameA( buffer, sizeof(buff2), buff2, NULL );
    716     filename = HEAP_strdupA( GetProcessHeap(), 0, buff2 );
     750    filename = heap_strdup( buff2 );
    717751
    718752    if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTUP, FALSE ))
     
    962996
    963997                    SHGetPathFromIDListA(&lpLinkHeader->Pidl, sTemp);
    964                     This->sPath = HEAP_strdupA ( GetProcessHeap(), 0, sTemp);
     998                    This->sPath = heap_strdup( sTemp );
    965999                  }
    9661000                  This->wHotKey = lpLinkHeader->wHotKey;
     
    11261160            HeapFree(GetProcessHeap(), 0, This->sArgs);
    11271161
    1128 
    11291162          if (This->sWorkDir)
    11301163            HeapFree(GetProcessHeap(), 0, This->sWorkDir);
     
    11991232        if (This->sDescription)
    12001233            HeapFree(GetProcessHeap(), 0, This->sDescription);
    1201         if (!(This->sDescription = HEAP_strdupA(GetProcessHeap(), 0, pszName)))
     1234        if (!(This->sDescription = heap_strdup(pszName)))
    12021235            return E_OUTOFMEMORY;
    12031236
     
    12221255        if (This->sWorkDir)
    12231256            HeapFree(GetProcessHeap(), 0, This->sWorkDir);
    1224         if (!(This->sWorkDir = HEAP_strdupA(GetProcessHeap(), 0, pszDir)))
     1257        if (!(This->sWorkDir = heap_strdup(pszDir)))
    12251258            return E_OUTOFMEMORY;
    12261259
     
    12451278        if (This->sArgs)
    12461279            HeapFree(GetProcessHeap(), 0, This->sArgs);
    1247         if (!(This->sArgs = HEAP_strdupA(GetProcessHeap(), 0, pszArgs)))
     1280        if (!(This->sArgs = heap_strdup(pszArgs)))
    12481281            return E_OUTOFMEMORY;
    12491282
     
    13041337        if (This->sIcoPath)
    13051338            HeapFree(GetProcessHeap(), 0, This->sIcoPath);
    1306         if (!(This->sIcoPath = HEAP_strdupA(GetProcessHeap(), 0, pszIconPath)))
     1339        if (!(This->sIcoPath = heap_strdup(pszIconPath)))
    13071340            return E_OUTOFMEMORY;       
    13081341        This->iIcoNdx = iIcon;
     
    13321365        if (This->sPath)
    13331366            HeapFree(GetProcessHeap(), 0, This->sPath);
    1334         if (!(This->sPath = HEAP_strdupA(GetProcessHeap(), 0, pszFile)))
     1367        if (!(This->sPath = heap_strdup(pszFile)))
    13351368            return E_OUTOFMEMORY;
    13361369       
Note: See TracChangeset for help on using the changeset viewer.