Changeset 1353 for trunk/src/shell32/shell.cpp
- Timestamp:
- Oct 19, 1999, 12:23:27 PM (26 years ago)
- File:
-
- 1 edited
-
trunk/src/shell32/shell.cpp (modified) (20 diffs)
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 2 3 /* 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 4 10 * 5 11 * 1998 Marcus Meissner 6 12 */ 13 14 15 /***************************************************************************** 16 * Includes * 17 *****************************************************************************/ 18 19 #include <odin.h> 20 #include <odinwrap.h> 21 #include <os2sel.h> 22 7 23 #include <assert.h> 8 24 #include <stdlib.h> … … 10 26 //#include <unistd.h> 11 27 #include <ctype.h> 12 13 #include <odin.h>14 28 15 29 #define ICOM_CINTERFACE 1 … … 38 52 #include <misc.h> 39 53 40 DECLARE_DEBUG_CHANNEL(exec) 41 DECLARE_DEBUG_CHANNEL(shell) 54 55 /***************************************************************************** 56 * Implementation * 57 *****************************************************************************/ 58 59 ODINDEBUGCHANNEL(SHELL32-SHELL) 60 42 61 43 62 /* .ICO file ICONDIR definitions */ … … 47 66 typedef struct 48 67 { 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 */ 51 70 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? */ 57 76 } icoICONDIRENTRY, *LPicoICONDIRENTRY; 58 77 59 78 typedef struct 60 79 { 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? */ 64 83 icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */ 65 84 } icoICONDIR, *LPicoICONDIR; … … 67 86 #include "poppack.h" 68 87 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;88 static const char* lpstrMsgWndCreated = "OTHERWINDOWCREATED"; 89 static const char* lpstrMsgWndDestroyed = "OTHERWINDOWDESTROYED"; 90 static const char* lpstrMsgShellActivate = "ACTIVATESHELLWINDOW"; 91 92 static HWND16 SHELL_hWnd = 0; 93 static HHOOK SHELL_hHook = 0; 94 static UINT16 uMsgWndCreated = 0; 95 static UINT16 uMsgWndDestroyed = 0; 96 static UINT16 uMsgShellActivate = 0; 97 HINSTANCE16 SHELL_hInstance = 0; 79 98 HINSTANCE SHELL_hInstance32; 80 99 static int SHELL_Attach = 0; … … 82 101 83 102 /************************************************************************* 84 * DragAcceptFiles32 [SHELL32.54] 85 */ 86 void WINAPI DragAcceptFiles(HWND hWnd, BOOL b) 103 * DragAcceptFiles32 [SHELL32.54] 104 */ 105 106 ODINPROCEDURE2(DragAcceptFiles, HWND, hWnd, 107 BOOL, b) 87 108 { 88 109 LONG exstyle; 89 110 90 91 111 if( !IsWindow(hWnd) ) 92 return;112 return; 93 113 exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE); 94 114 if (b)exstyle |= WS_EX_ACCEPTFILES; 95 else exstyle &= ~WS_EX_ACCEPTFILES;115 else exstyle &= ~WS_EX_ACCEPTFILES; 96 116 SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle); 97 117 } 98 118 99 119 /************************************************************************* 100 * SHELL_DragQueryFile[internal]120 * SHELL_DragQueryFile [internal] 101 121 * 102 122 */ 103 123 static UINT SHELL_DragQueryFile(LPSTR lpDrop, LPWSTR lpwDrop, UINT lFile, 104 LPSTR lpszFile, LPWSTR lpszwFile, UINT lLength)124 LPSTR lpszFile, LPWSTR lpszwFile, UINT lLength) 105 125 { 106 126 UINT i; … … 109 129 if (lpDrop) { 110 130 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; 114 134 } 115 135 } 116 136 if (lpwDrop) { 117 137 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; 121 141 } 122 142 } … … 140 160 141 161 /************************************************************************* 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 165 ODINFUNCTION4(UINT, DragQueryFileA, HDROP, hDrop, 166 UINT, lFile, 167 LPSTR, lpszFile, 168 UINT, lLength) 146 169 { /* hDrop is a global memory block allocated with GMEM_SHARE 147 170 * with DROPFILESTRUCT as a header and filenames following … … 151 174 LPSTR lpCurrent; 152 175 UINT i; 153 154 TRACE_(shell)("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength);155 176 156 177 lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop); … … 165 186 166 187 /************************************************************************* 167 * DragQueryFile32W [shell32.133] 168 */ 169 UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, 170 UINT lLength) 188 * DragQueryFile32W [shell32.133] 189 */ 190 ODINFUNCTION4(UINT, DragQueryFileW, HDROP, hDrop, 191 UINT, lFile, 192 LPWSTR, lpszwFile, 193 UINT, lLength) 171 194 { 172 195 LPDROPFILESTRUCT lpDropFileStruct; 173 196 LPWSTR lpwCurrent; 174 197 UINT i; 175 176 TRACE_(shell)("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);177 198 178 199 lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop); … … 202 223 *****************************************************************************/ 203 224 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 225 ODINFUNCTION4(UINT, DragQueryFileAorW, 226 HDROP, hDrop, 227 UINT, iFile, 228 LPTSTR, lpszFile, 229 UINT, cch) 230 { 215 231 // @@@PH maybe they want automatic determination here 216 232 if (VERSION_OsIsUnicode()) … … 222 238 223 239 /************************************************************************* 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 */ 242 ODINPROCEDURE1(DragFinish, HDROP, h) 243 { 244 GlobalFree((HGLOBAL)h); 245 } 246 247 248 /************************************************************************* 249 * DragQueryPoint32 [SHELL32.135] 250 */ 251 ODINFUNCTION2(BOOL, DragQueryPoint, 252 HDROP, hDrop, 253 POINT*, p) 236 254 { 237 255 LPDROPFILESTRUCT lpDropFileStruct; 238 256 BOOL bRet; 239 TRACE_(shell)("\n"); 257 240 258 lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop); 241 259 … … 248 266 249 267 /************************************************************************* 250 * SHELL_FindExecutable [Internal]268 * SHELL_FindExecutable [Internal] 251 269 * 252 270 * Utility for code sharing between FindExecutable and ShellExecute … … 267 285 char xlpFile[256]; /* result of SearchPath */ 268 286 269 TRACE_(shell)("%s\n", (lpFile != NULL?lpFile:"-") ); 287 dprintf(("SHELL32:SHELL:SHELL_FindExecutable(%s,%s,%08xh)\n", 288 lpFile, 289 lpOperation, 290 lpResult)); 270 291 271 292 lpResult[0]='\0'; /* Start off with an empty return string */ … … 273 294 /* trap NULL parameters on entry */ 274 295 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)); 277 298 return 2; /* File not found. Close enough, I guess. */ 278 299 } 279 300 280 301 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")); 282 303 lpFile = xlpFile; 283 304 } … … 285 306 /* First thing we need is the file's extension */ 286 307 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)); 290 312 291 313 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")); 293 315 return 31; /* no association */ 294 316 } … … 297 319 lstrcpynA( tmpext, extension, 5 ); 298 320 CharLowerA( tmpext ); 299 TRACE_(shell)("%s file\n", tmpext); 321 322 323 dprintf(("SHELL32:SHELL:SHELL_FindExecutable(%s file)\n", tmpext)); 300 324 301 325 /* Three places to check: */ … … 311 335 * got a lot more to worry about than running a program... */ 312 336 if ( GetProfileStringA("windows", "programs", "exe pif bat com", 313 buffer, sizeof(buffer)) > 0 )337 buffer, sizeof(buffer)) > 0 ) 314 338 { for (i=0;i<strlen(buffer); i++) buffer[i]=tolower(buffer[i]); 315 339 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 } 335 360 336 361 /* Check registry */ … … 338 363 &filetypelen ) == ERROR_SUCCESS ) 339 364 { 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, 349 375 &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 } 367 393 } 368 394 else /* Check win.ini */ 369 395 { 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, 373 399 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)); 395 421 return retval; 396 422 } … … 398 424 399 425 /************************************************************************* 400 * SHELL_GetResourceTable426 * SHELL_GetResourceTable 401 427 */ 402 428 static 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 ? */ 413 441 if (mz_header.e_cblp == 1) 414 { /* ICONHEADER.idType, must be 1 */415 *retptr = (LPBYTE)-1;416 return 1;417 }418 else419 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_HEADERne_header;433 LPBYTEpTypeInfo = (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; 442 470 443 471 //@@@PH no NE support 444 472 #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 } 455 483 #endif 456 484 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] 466 494 * 467 495 * Return icon for given file (either from file itself or from associated 468 496 * executable) and patch parameters if needed. 469 497 */ 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 } 498 ODINFUNCTION3(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.
