Hi all,
this patch lets InternalExtractIcon16 load icons from builtin DLLs
(one program called ExtractIconA to retrieve SHELL32 space icons,
which branches to InternalExtractIcon16)
Please tell me whether this code is ok or not.
(it's a bit rude ;)
And of course we should try to implement a function that says whether a
module is builtin or not...
(as doing LoadLibrary "just to check" is quite some overhead)
How to do that ?
Andreas Mohr
Determining best CVS host...
Using CVSROOT :pserver:[EMAIL PROTECTED]:/home/wine
Index: dlls/shell32/shell.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell.c,v
retrieving revision 1.16
diff -u -r1.16 shell.c
--- dlls/shell32/shell.c 2000/08/14 14:41:21 1.16
+++ dlls/shell32/shell.c 2000/09/22 01:17:38
@@ -666,7 +666,7 @@
LPBYTE pData;
OFSTRUCT ofs;
DWORD sig;
- HFILE hFile = OpenFile( lpszExeFileName, &ofs, OF_READ );
+ HFILE hFile;
UINT16 iconDirCount = 0,iconCount = 0;
LPBYTE peimage;
HANDLE fmapping;
@@ -674,13 +674,33 @@
TRACE("(%04x,file %s,start %d,extract %d\n",
hInstance, lpszExeFileName, nIconIndex, n);
- if( hFile == HFILE_ERROR || !n )
+ if( !n )
return 0;
+ hFile = OpenFile( lpszExeFileName, &ofs, OF_READ );
+
hRet = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, sizeof(HICON16)*n);
RetPtr = (HICON16*)GlobalLock16(hRet);
+
+ if (hFile == HFILE_ERROR)
+ { /* not found - load from builtin module if available */
+ HINSTANCE hInst = (HINSTANCE)LoadLibrary16(lpszExeFileName);
+
+ if (hInst < 32) /* hmm, no Win16 module - try Win32 :-) */
+ hInst = LoadLibraryA(lpszExeFileName);
+ if (hInst)
+ {
+ int i;
+ for (i=nIconIndex; i < nIconIndex + n; i++)
+ RetPtr[i-nIconIndex] =
+ (HICON16)LoadIconA(hInst, (LPCSTR)(DWORD)i);
+ FreeLibrary(hInst);
+ return hRet;
+ }
+ return 0;
+ }
- *RetPtr = (n == 0xFFFF)? 0: 1; /* error return values */
+ *RetPtr = (n == 0xFFFF)? 0 : 1; /* error return values */
sig = SHELL_GetResourceTable(hFile,&pData);
@@ -903,7 +923,7 @@
}
RetPtr[i] =
CreateIconFromResourceEx(idata,idataent->Size,TRUE,0x00030000,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON),0);
}
- goto end_3; /* sucess */
+ goto end_3; /* success */
}
goto end_1; /* return array with icon handles */