Ignore:
Timestamp:
Oct 19, 1999, 12:23:27 PM (26 years ago)
Author:
phaller
Message:

Fix: debug info

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/shell.cpp

    r1215 r1353  
    1 /* $Id: shell.cpp,v 1.2 1999-10-09 11:17:01 sandervl Exp $ */
     1/* $Id: shell.cpp,v 1.3 1999-10-19 10:23:27 phaller Exp $ */
     2
    23/*
    3  *                              Shell Library Functions
     4 * Win32 SHELL32 for OS/2
     5 *
     6 * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
     7 * Project Odin Software License can be found in LICENSE.TXT
     8 *
     9 *             Shell Library Functions
    410 *
    511 *  1998 Marcus Meissner
    612 */
     13
     14
     15/*****************************************************************************
     16 * Includes                                                                  *
     17 *****************************************************************************/
     18
     19#include <odin.h>
     20#include <odinwrap.h>
     21#include <os2sel.h>
     22
    723#include <assert.h>
    824#include <stdlib.h>
     
    1026//#include <unistd.h>
    1127#include <ctype.h>
    12 
    13 #include <odin.h>
    1428
    1529#define ICOM_CINTERFACE 1
     
    3852#include <misc.h>
    3953
    40 DECLARE_DEBUG_CHANNEL(exec)
    41 DECLARE_DEBUG_CHANNEL(shell)
     54
     55/*****************************************************************************
     56 * Implementation                                                            *
     57 *****************************************************************************/
     58
     59ODINDEBUGCHANNEL(SHELL32-SHELL)
     60
    4261
    4362/* .ICO file ICONDIR definitions */
     
    4766typedef struct
    4867{
    49     BYTE        bWidth;          /* Width, in pixels, of the image      */
    50     BYTE        bHeight;         /* Height, in pixels, of the image     */
     68    BYTE        bWidth;          /* Width, in pixels, of the image  */
     69    BYTE        bHeight;         /* Height, in pixels, of the image */
    5170    BYTE        bColorCount;     /* Number of colors in image (0 if >=8bpp) */
    52     BYTE        bReserved;       /* Reserved ( must be 0)               */
    53     WORD        wPlanes;         /* Color Planes                        */
    54     WORD        wBitCount;       /* Bits per pixel                      */
    55     DWORD       dwBytesInRes;    /* How many bytes in this resource?    */
    56     DWORD       dwImageOffset;   /* Where in the file is this image?    */
     71    BYTE        bReserved;       /* Reserved ( must be 0)     */
     72    WORD        wPlanes;         /* Color Planes        */
     73    WORD        wBitCount;       /* Bits per pixel         */
     74    DWORD       dwBytesInRes;    /* How many bytes in this resource?   */
     75    DWORD       dwImageOffset;   /* Where in the file is this image?   */
    5776} icoICONDIRENTRY, *LPicoICONDIRENTRY;
    5877
    5978typedef struct
    6079{
    61     WORD            idReserved;   /* Reserved (must be 0)               */
    62     WORD            idType;       /* Resource Type (1 for icons)        */
    63     WORD            idCount;      /* How many images?                   */
     80    WORD            idReserved;   /* Reserved (must be 0)     */
     81    WORD            idType;       /* Resource Type (1 for icons) */
     82    WORD            idCount;      /* How many images?         */
    6483    icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */
    6584} icoICONDIR, *LPicoICONDIR;
     
    6786#include "poppack.h"
    6887
    69 static const char*      lpstrMsgWndCreated = "OTHERWINDOWCREATED";
    70 static const char*      lpstrMsgWndDestroyed = "OTHERWINDOWDESTROYED";
    71 static const char*      lpstrMsgShellActivate = "ACTIVATESHELLWINDOW";
    72 
    73 static HWND16   SHELL_hWnd = 0;
    74 static HHOOK    SHELL_hHook = 0;
    75 static UINT16   uMsgWndCreated = 0;
    76 static UINT16   uMsgWndDestroyed = 0;
    77 static UINT16   uMsgShellActivate = 0;
    78 HINSTANCE16     SHELL_hInstance = 0;
     88static const char* lpstrMsgWndCreated    = "OTHERWINDOWCREATED";
     89static const char* lpstrMsgWndDestroyed = "OTHERWINDOWDESTROYED";
     90static const char* lpstrMsgShellActivate = "ACTIVATESHELLWINDOW";
     91
     92static HWND16  SHELL_hWnd = 0;
     93static HHOOK   SHELL_hHook = 0;
     94static UINT16  uMsgWndCreated = 0;
     95static UINT16  uMsgWndDestroyed = 0;
     96static UINT16  uMsgShellActivate = 0;
     97HINSTANCE16 SHELL_hInstance = 0;
    7998HINSTANCE SHELL_hInstance32;
    8099static int SHELL_Attach = 0;
     
    82101
    83102/*************************************************************************
    84  *                              DragAcceptFiles32               [SHELL32.54]
    85  */
    86 void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
     103 *          DragAcceptFiles32               [SHELL32.54]
     104 */
     105
     106ODINPROCEDURE2(DragAcceptFiles, HWND, hWnd,
     107                                BOOL, b)
    87108{
    88109  LONG exstyle;
    89110
    90 
    91111  if( !IsWindow(hWnd) )
    92         return;
     112   return;
    93113  exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
    94114  if (b)exstyle |= WS_EX_ACCEPTFILES;
    95   else  exstyle &= ~WS_EX_ACCEPTFILES;
     115  else   exstyle &= ~WS_EX_ACCEPTFILES;
    96116  SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
    97117}
    98118
    99119/*************************************************************************
    100  *                              SHELL_DragQueryFile     [internal]
     120 *          SHELL_DragQueryFile          [internal]
    101121 *
    102122 */
    103123static UINT SHELL_DragQueryFile(LPSTR lpDrop, LPWSTR lpwDrop, UINT lFile,
    104                                   LPSTR lpszFile, LPWSTR lpszwFile, UINT lLength)
     124              LPSTR lpszFile, LPWSTR lpszwFile, UINT lLength)
    105125{
    106126    UINT i;
     
    109129    if (lpDrop) {
    110130    while (i++ < lFile) {
    111         while (*lpDrop++); /* skip filename */
    112         if (!*lpDrop)
    113           return (lFile == 0xFFFFFFFF) ? i : 0;
     131   while (*lpDrop++); /* skip filename */
     132   if (!*lpDrop)
     133     return (lFile == 0xFFFFFFFF) ? i : 0;
    114134      }
    115135    }
    116136    if (lpwDrop) {
    117137      while (i++ < lFile) {
    118         while (*lpwDrop++); /* skip filename */
    119         if (!*lpwDrop)
    120           return (lFile == 0xFFFFFFFF) ? i : 0;
     138   while (*lpwDrop++); /* skip filename */
     139   if (!*lpwDrop)
     140     return (lFile == 0xFFFFFFFF) ? i : 0;
    121141      }
    122142    }
     
    140160
    141161/*************************************************************************
    142  *                              DragQueryFile32A        [SHELL32.81] [shell32.82]
    143  */
    144 UINT WINAPI DragQueryFileA(HDROP hDrop, UINT lFile, LPSTR lpszFile,
    145                               UINT lLength)
     162 *          DragQueryFile32A             [SHELL32.81] [shell32.82]
     163 */
     164
     165ODINFUNCTION4(UINT, DragQueryFileA, HDROP, hDrop,
     166                                    UINT,  lFile,
     167                                    LPSTR, lpszFile,
     168                                    UINT,  lLength)
    146169{ /* hDrop is a global memory block allocated with GMEM_SHARE
    147170     * with DROPFILESTRUCT as a header and filenames following
     
    151174    LPSTR lpCurrent;
    152175    UINT i;
    153 
    154     TRACE_(shell)("(%08x, %x, %p, %u)\n",       hDrop,lFile,lpszFile,lLength);
    155176
    156177    lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
     
    165186
    166187/*************************************************************************
    167  *                              DragQueryFile32W        [shell32.133]
    168  */
    169 UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile,
    170                               UINT lLength)
     188 *          DragQueryFile32W             [shell32.133]
     189 */
     190ODINFUNCTION4(UINT, DragQueryFileW, HDROP,  hDrop,
     191                                    UINT,   lFile,
     192                                    LPWSTR, lpszwFile,
     193                                    UINT,   lLength)
    171194{
    172195    LPDROPFILESTRUCT lpDropFileStruct;
    173196    LPWSTR lpwCurrent;
    174197    UINT i;
    175 
    176     TRACE_(shell)("(%08x, %x, %p, %u)\n",       hDrop,lFile,lpszwFile,lLength);
    177198
    178199    lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
     
    202223 *****************************************************************************/
    203224
    204 UINT WIN32API DragQueryFileAorW(HDROP  hDrop,
    205                                 UINT   iFile,
    206                                 LPTSTR lpszFile,
    207                                 UINT   cch)
    208 {
    209   dprintf(("SHELL32: DragQueryFileAorW(%08xh,%08xh,%s,%08xh).\n",
    210            hDrop,
    211            iFile,
    212            lpszFile,
    213            cch));
    214 
     225ODINFUNCTION4(UINT,   DragQueryFileAorW,
     226              HDROP,  hDrop,
     227              UINT,   iFile,
     228              LPTSTR, lpszFile,
     229              UINT,   cch)
     230{
    215231  // @@@PH maybe they want automatic determination here
    216232  if (VERSION_OsIsUnicode())
     
    222238
    223239/*************************************************************************
    224  *                              DragFinish32            [SHELL32.80]
    225  */
    226 void WINAPI DragFinish(HDROP h)
    227 { TRACE_(shell)("\n");
    228     GlobalFree((HGLOBAL)h);
    229 }
    230 
    231 
    232 /*************************************************************************
    233  *                              DragQueryPoint32                [SHELL32.135]
    234  */
    235 BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
     240 *          DragFinish32                    [SHELL32.80]
     241 */
     242ODINPROCEDURE1(DragFinish, HDROP, h)
     243{
     244  GlobalFree((HGLOBAL)h);
     245}
     246
     247
     248/*************************************************************************
     249 *          DragQueryPoint32                [SHELL32.135]
     250 */
     251ODINFUNCTION2(BOOL,   DragQueryPoint,
     252              HDROP,  hDrop,
     253              POINT*, p)
    236254{
    237255  LPDROPFILESTRUCT lpDropFileStruct;
    238256  BOOL             bRet;
    239   TRACE_(shell)("\n");
     257
    240258  lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
    241259
     
    248266
    249267/*************************************************************************
    250  *      SHELL_FindExecutable [Internal]
     268 * SHELL_FindExecutable [Internal]
    251269 *
    252270 * Utility for code sharing between FindExecutable and ShellExecute
     
    267285    char xlpFile[256];      /* result of SearchPath */
    268286
    269   TRACE_(shell)("%s\n", (lpFile != NULL?lpFile:"-") );
     287    dprintf(("SHELL32:SHELL:SHELL_FindExecutable(%s,%s,%08xh)\n",
     288             lpFile,
     289             lpOperation,
     290             lpResult));
    270291
    271292    lpResult[0]='\0'; /* Start off with an empty return string */
     
    273294    /* trap NULL parameters on entry */
    274295    if (( lpFile == NULL ) || ( lpResult == NULL ) || ( lpOperation == NULL ))
    275   { WARN_(exec)("(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
    276            lpFile, lpOperation, lpResult);
     296  { dprintf(("SHELL32:SHELL:SHELL_FindExecutable(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
     297           lpFile, lpOperation, lpResult));
    277298        return 2; /* File not found. Close enough, I guess. */
    278299    }
    279300
    280301    if (SearchPathA( NULL, lpFile,".exe",sizeof(xlpFile),xlpFile,NULL))
    281   { TRACE_(shell)("SearchPath32A returned non-zero\n");
     302  {  dprintf(("SHELL32:SHELL:SHELL_FindExecutable(SearchPath32A returned non-zero\n"));
    282303        lpFile = xlpFile;
    283304    }
     
    285306    /* First thing we need is the file's extension */
    286307    extension = strrchr( xlpFile, '.' ); /* Assume last "." is the one; */
    287                                         /* File->Run in progman uses */
    288                                         /* .\FILE.EXE :( */
    289   TRACE_(shell)("xlpFile=%s,extension=%s\n", xlpFile, extension);
     308               /* File->Run in progman uses */
     309               /* .\FILE.EXE :( */
     310    dprintf(("SHELL32:SHELL:SHELL_FindExecutable(xlpFile=%s,extension=%s)\n",
     311             xlpFile, extension));
    290312
    291313    if ((extension == NULL) || (extension == &xlpFile[strlen(xlpFile)]))
    292   { WARN_(shell)("Returning 31 - No association\n");
     314  { dprintf(("SHELL32:SHELL:SHELL_FindExecutable Returning 31 - No association\n"));
    293315        return 31; /* no association */
    294316    }
     
    297319    lstrcpynA( tmpext, extension, 5 );
    298320    CharLowerA( tmpext );
    299   TRACE_(shell)("%s file\n", tmpext);
     321
     322
     323    dprintf(("SHELL32:SHELL:SHELL_FindExecutable(%s file)\n", tmpext));
    300324
    301325    /* Three places to check: */
     
    311335     * got a lot more to worry about than running a program... */
    312336    if ( GetProfileStringA("windows", "programs", "exe pif bat com",
    313                                                   buffer, sizeof(buffer)) > 0 )
     337                    buffer, sizeof(buffer)) > 0 )
    314338  { for (i=0;i<strlen(buffer); i++) buffer[i]=tolower(buffer[i]);
    315339
    316                 tok = strtok(buffer, " \t"); /* ? */
    317                 while( tok!= NULL)
    318                   {
    319                         if (strcmp(tok, &tmpext[1])==0) /* have to skip the leading "." */
    320                           {
    321                                 strcpy(lpResult, xlpFile);
    322                                 /* Need to perhaps check that the file has a path
    323                                  * attached */
    324         TRACE_(shell)("found %s\n", lpResult);
    325                                 return 33;
    326 
    327                 /* Greater than 32 to indicate success FIXME According to the
    328                  * docs, I should be returning a handle for the
    329                  * executable. Does this mean I'm supposed to open the
    330                  * executable file or something? More RTFM, I guess... */
    331                           }
    332                         tok=strtok(NULL, " \t");
    333                   }
    334           }
     340      tok = strtok(buffer, " \t"); /* ? */
     341      while( tok!= NULL)
     342        {
     343         if (strcmp(tok, &tmpext[1])==0) /* have to skip the leading "." */
     344           {
     345            strcpy(lpResult, xlpFile);
     346            /* Need to perhaps check that the file has a path
     347             * attached */
     348            dprintf(("SHELL32:SHELL:SHELL_FindExecutable found %s\n",
     349                     lpResult));
     350            return 33;
     351
     352      /* Greater than 32 to indicate success FIXME According to the
     353       * docs, I should be returning a handle for the
     354       * executable. Does this mean I'm supposed to open the
     355       * executable file or something? More RTFM, I guess... */
     356           }
     357         tok=strtok(NULL, " \t");
     358        }
     359     }
    335360
    336361    /* Check registry */
     
    338363                         &filetypelen ) == ERROR_SUCCESS )
    339364    {
    340         filetype[filetypelen]='\0';
    341   TRACE_(shell)("File type: %s\n", filetype);
    342 
    343         /* Looking for ...buffer\shell\lpOperation\command */
    344         strcat( filetype, "\\shell\\" );
    345         strcat( filetype, lpOperation );
    346         strcat( filetype, "\\command" );
    347        
    348         if (RegQueryValueA( HKEY_CLASSES_ROOT, filetype, command,
     365   filetype[filetypelen]='\0';
     366    dprintf(("SHELL32:SHELL:SHELL_FindExecutable(File type: %s)\n",
     367             filetype));
     368
     369   /* Looking for ...buffer\shell\lpOperation\command */
     370   strcat( filetype, "\\shell\\" );
     371   strcat( filetype, lpOperation );
     372   strcat( filetype, "\\command" );
     373
     374   if (RegQueryValueA( HKEY_CLASSES_ROOT, filetype, command,
    349375                             &commandlen ) == ERROR_SUCCESS )
    350         {
    351             /* Is there a replace() function anywhere? */
    352             command[commandlen]='\0';
    353             strcpy( lpResult, command );
    354             tok=strstr( lpResult, "%1" );
    355             if (tok != NULL)
    356             {
    357                 tok[0]='\0'; /* truncate string at the percent */
    358                 strcat( lpResult, xlpFile ); /* what if no dir in xlpFile? */
    359                 tok=strstr( command, "%1" );
    360                 if ((tok!=NULL) && (strlen(tok)>2))
    361                 {
    362                     strcat( lpResult, &tok[2] );
    363                 }
    364             }
    365             retval=33; /* FIXME see above */
    366         }
     376   {
     377       /* Is there a replace() function anywhere? */
     378       command[commandlen]='\0';
     379       strcpy( lpResult, command );
     380       tok=strstr( lpResult, "%1" );
     381       if (tok != NULL)
     382       {
     383      tok[0]='\0'; /* truncate string at the percent */
     384      strcat( lpResult, xlpFile ); /* what if no dir in xlpFile? */
     385      tok=strstr( command, "%1" );
     386      if ((tok!=NULL) && (strlen(tok)>2))
     387      {
     388          strcat( lpResult, &tok[2] );
     389      }
     390       }
     391       retval=33; /* FIXME see above */
     392   }
    367393    }
    368394    else /* Check win.ini */
    369395    {
    370         /* Toss the leading dot */
    371         extension++;
    372         if ( GetProfileStringA( "extensions", extension, "", command,
     396   /* Toss the leading dot */
     397   extension++;
     398   if ( GetProfileStringA( "extensions", extension, "", command,
    373399                                  sizeof(command)) > 0)
    374           {
    375                 if (strlen(command)!=0)
    376                   {
    377                         strcpy( lpResult, command );
    378                         tok=strstr( lpResult, "^" ); /* should be ^.extension? */
    379                         if (tok != NULL)
    380                           {
    381                                 tok[0]='\0';
    382                                 strcat( lpResult, xlpFile ); /* what if no dir in xlpFile? */
    383                                 tok=strstr( command, "^" ); /* see above */
    384                                 if ((tok != NULL) && (strlen(tok)>5))
    385                                   {
    386                                         strcat( lpResult, &tok[5]);
    387                                   }
    388                           }
    389                         retval=33; /* FIXME - see above */
    390                   }
    391           }
    392         }
    393 
    394     TRACE_(shell)("returning %s\n", lpResult);
     400     {
     401      if (strlen(command)!=0)
     402        {
     403         strcpy( lpResult, command );
     404         tok=strstr( lpResult, "^" ); /* should be ^.extension? */
     405         if (tok != NULL)
     406           {
     407            tok[0]='\0';
     408            strcat( lpResult, xlpFile ); /* what if no dir in xlpFile? */
     409            tok=strstr( command, "^" ); /* see above */
     410            if ((tok != NULL) && (strlen(tok)>5))
     411              {
     412               strcat( lpResult, &tok[5]);
     413              }
     414           }
     415         retval=33; /* FIXME - see above */
     416        }
     417     }
     418   }
     419
     420    dprintf(("SHELL32:SHELL:SHELL_FindExecutable (returning %s)\n", lpResult));
    395421    return retval;
    396422}
     
    398424
    399425/*************************************************************************
    400  *                              SHELL_GetResourceTable
     426 *          SHELL_GetResourceTable
    401427 */
    402428static DWORD SHELL_GetResourceTable(HFILE hFile,LPBYTE *retptr)
    403 {       IMAGE_DOS_HEADER        mz_header;
    404         char                    magic[4];
    405         int                     size;
    406 
    407         TRACE_(shell)("\n");
    408 
    409         *retptr = NULL;
    410         _llseek( hFile, 0, SEEK_SET );
    411         if ((_lread(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) || (mz_header.e_magic != IMAGE_DOS_SIGNATURE))
    412         { /* .ICO file ? */
     429{  IMAGE_DOS_HEADER                      mz_header;
     430   char        magic[4];
     431   int         size;
     432
     433   dprintf(("SHELL32:Shell:SHELL_GetResourceTable(%08xh,%08xh)\n",
     434            hFile,
     435            retptr));
     436
     437   *retptr = NULL;
     438   _llseek( hFile, 0, SEEK_SET );
     439   if ((_lread(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) || (mz_header.e_magic != IMAGE_DOS_SIGNATURE))
     440   { /* .ICO file ? */
    413441          if (mz_header.e_cblp == 1)
    414           { /* ICONHEADER.idType, must be 1 */
    415             *retptr = (LPBYTE)-1;
    416             return 1;
    417           }
    418           else
    419             return 0; /* failed */
    420         }
    421         _llseek( hFile, mz_header.e_lfanew, SEEK_SET );
    422 
    423         if (_lread( hFile, magic, sizeof(magic) ) != sizeof(magic))
    424           return 0;
    425 
    426         _llseek( hFile, mz_header.e_lfanew, SEEK_SET);
    427 
    428         if (*(DWORD*)magic  == IMAGE_NT_SIGNATURE)
    429           return IMAGE_NT_SIGNATURE;
    430 
    431         if (*(WORD*)magic == IMAGE_OS2_SIGNATURE)
    432         { IMAGE_OS2_HEADER      ne_header;
    433           LPBYTE                pTypeInfo = (LPBYTE)-1;
    434 
    435           if (_lread(hFile,&ne_header,sizeof(ne_header))!=sizeof(ne_header))
    436             return 0;
    437 
    438           if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE)
    439             return 0;
    440 
    441           size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
     442     { /* ICONHEADER.idType, must be 1 */
     443       *retptr = (LPBYTE)-1;
     444       return 1;
     445     }
     446     else
     447       return 0; /* failed */
     448   }
     449   _llseek( hFile, mz_header.e_lfanew, SEEK_SET );
     450
     451   if (_lread( hFile, magic, sizeof(magic) ) != sizeof(magic))
     452     return 0;
     453
     454   _llseek( hFile, mz_header.e_lfanew, SEEK_SET);
     455
     456   if (*(DWORD*)magic  == IMAGE_NT_SIGNATURE)
     457     return IMAGE_NT_SIGNATURE;
     458
     459   if (*(WORD*)magic == IMAGE_OS2_SIGNATURE)
     460   { IMAGE_OS2_HEADER                    ne_header;
     461     LPBYTE    pTypeInfo = (LPBYTE)-1;
     462
     463     if (_lread(hFile,&ne_header,sizeof(ne_header))!=sizeof(ne_header))
     464       return 0;
     465
     466     if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE)
     467       return 0;
     468
     469     size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
    442470
    443471//@@@PH no NE support
    444472#if 0
    445           if( size > sizeof(NE_TYPEINFO) )
    446           { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
    447             if( pTypeInfo )
    448             { _llseek(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
    449               if( _lread( hFile, (char*)pTypeInfo, size) != size )
    450               { HeapFree( GetProcessHeap(), 0, pTypeInfo);
    451                 pTypeInfo = NULL;
    452               }
    453             }
    454           }
     473     if( size > sizeof(NE_TYPEINFO) )
     474     { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
     475       if( pTypeInfo )
     476       { _llseek(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
     477         if( _lread( hFile, (char*)pTypeInfo, size) != size )
     478         { HeapFree( GetProcessHeap(), 0, pTypeInfo);
     479      pTypeInfo = NULL;
     480         }
     481       }
     482     }
    455483#endif
    456484
    457           *retptr = pTypeInfo;
    458           return IMAGE_OS2_SIGNATURE;
    459         }
    460         return 0; /* failed */
    461 }
    462 
    463 
    464 /*************************************************************************
    465  *                              ExtractAssociatedIcon   [SHELL.36]
     485     *retptr = pTypeInfo;
     486     return IMAGE_OS2_SIGNATURE;
     487   }
     488   return 0; /* failed */
     489}
     490
     491
     492/*************************************************************************
     493 *          ExtractAssociatedIcon        [SHELL.36]
    466494 *
    467495 * Return icon for given file (either from file itself or from associated
    468496 * executable) and patch parameters if needed.
    469497 */
    470 HICON WINAPI ExtractAssociatedIconA(HINSTANCE hInst, LPSTR lpIconPath, LPWORD lpiIcon)
    471 {       TRACE_(shell)("\n");
    472         HICON hIcon;
    473 
    474         hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
    475 
    476         if( hIcon < 2 )
    477         { if( hIcon == 1 ) /* no icons found in given file */
    478           { char  tempPath[0x104];
    479             UINT16  uRet = FindExecutableA(lpIconPath,NULL,tempPath);
    480 
    481             if( uRet > 32 && tempPath[0] )
    482             { strcpy(lpIconPath,tempPath);
    483               hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
    484               if( hIcon > 2 )
    485                 return hIcon;
    486             }
    487             else hIcon = 0;
    488           }
    489 
    490           if( hIcon == 1 )
    491             *lpiIcon = 2;   /* MSDOS icon - we found .exe but no icons in it */
    492           else
    493             *lpiIcon = 6;   /* generic icon - found nothing */
    494 
    495           GetModuleFileNameA(hInst, lpIconPath, 0x80);
    496           hIcon = LoadIconA( hInst, (LPCSTR)*lpiIcon);
    497         }
    498         return hIcon;
    499 }
     498ODINFUNCTION3(HICON,     ExtractAssociatedIconA,
     499              HINSTANCE, hInst,
     500              LPSTR,     lpIconPath,
     501              LPWORD,    lpiIcon)
     502{
     503   HICON hIcon;
     504
     505   hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
     506
     507   if( hIcon < 2 )
     508   { if( hIcon == 1 ) /* no icons found in given file */
     509     { char  tempPath[0x104];
     510       UINT16  uRet = FindExecutableA(lpIconPath,NULL,tempPath);
     511
     512       if( uRet > 32 && tempPath[0] )
     513       { strcpy(lpIconPath,tempPath);
     514         hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
     515         if( hIcon > 2 )
     516           return hIcon;
     517       }
     518       else hIcon = 0;
     519     }
     520
     521     if( hIcon == 1 )
     522       *lpiIcon = 2;   /* MSDOS icon - we found .exe but no icons in it */
     523     else
     524       *lpiIcon = 6;   /* generic icon - found nothing */
     525
     526     GetModuleFileNameA(hInst, lpIconPath, 0x80);
     527     hIcon = LoadIconA( hInst, (LPCSTR)*lpiIcon);
     528   }
     529   return hIcon;
     530}
     531
Note: See TracChangeset for help on using the changeset viewer.