Make icon extraction for 16 bit icons work
Dmitry Timoshkov
dmitry at baikal.ru
Thu Mar 4 00:50:30 CST 2004
Hello,
Changelog:
Martin Pilka <mpilka at codeweavers.com>
Make icon extraction for 16 bit icons work.
--- cvs/hq/wine/programs/winemenubuilder/winemenubuilder.c Thu Jan 8 18:28:10 2004
+++ wine/programs/winemenubuilder/winemenubuilder.c Thu Mar 4 14:29:47 2004
@@ -54,6 +54,7 @@
#include "wine/debug.h"
#include "wine.xpm"
+#include "wine/winbase16.h"
WINE_DEFAULT_DEBUG_CHANNEL(menubuilder);
@@ -233,11 +234,52 @@ static BOOL ExtractFromEXEDLL(const char
int nMax = 0;
int nMaxBits = 0;
int i;
+ HINSTANCE16 hInstance16;
+ HRSRC16 hRsrc;
+ HGLOBAL16 handle = 0;
+ DWORD save_error = 0;
if (!(hModule = LoadLibraryExA(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE)))
{
- WINE_ERR("LoadLibraryExA (%s) failed, error %ld\n", szFileName, GetLastError());
- goto error1;
+ save_error = GetLastError();
+ }
+ if ((hInstance16 = LoadLibrary16(szFileName)) < 32)
+ {
+ if (!hModule) {
+ WINE_ERR("LoadLibraryExA (%s) failed, error %ld\n", szFileName, save_error);
+ WINE_ERR("LoadLibrary16 (%s) failed, error %ld\n", szFileName, GetLastError());
+ goto error1;
+ }
+ } else {
+ if (!(hRsrc = FindResource16( hInstance16, MAKEINTRESOURCE(1), (LPSTR)RT_ICON )))
+ {
+ WINE_ERR("FindResource16 failed, error %ld\n", GetLastError());
+ goto error16_1;
+ };
+ if (!(handle = LoadResource16( hInstance16, hRsrc )))
+ {
+ WINE_ERR("LoadResource16 failed, error %ld\n", GetLastError());
+ goto error16_1;
+ }
+ if (!(pIcon = LockResource16(handle)))
+ {
+ WINE_ERR("LockResource16 failed, error %ld\n", GetLastError());
+ goto error16_2;
+ }
+ if(!SaveIconResAsXPM(pIcon, szXPMFileName, szFileName))
+ {
+ WINE_ERR("Failed saving icon as XPM, error %ld\n", GetLastError());
+ goto error16_2;
+ }
+ FreeResource16( handle );
+ FreeLibrary16( hInstance16);
+ return TRUE;
+
+ error16_2:
+ FreeLibrary16(hInstance16);
+ error16_1:
+ FreeResource16(handle);
+ return FALSE;
}
if (nIndex < 0)
More information about the wine-patches
mailing list