VictorN
April 16th, 2003, 01:26 PM
Hi, guru!
I need to load some icons from external exe module.
I do so:
CString strHost = _T("blabla.exe")
HINSTANCE hInst = LoadLibrary(strHost);
if(hInst)
{
HICON hIcon = NULL;
pMenu->SetIconMode();
hIcon = (HICON)::LoadImage( hInst, MAKEINTRESOURCE (IDR_MAINFRAME), IMAGE_ICON, 16, 15, LR_DEFAULTCOLOR);
if(hIcon)
{
...
DestroyIcon(hIcon);
}
FreeLibrary(hInst );
}
It runs OK in NT/2000 but in Win98 I get hInst == NULL with GetLastError() == ERROR_BAD_FORMAT
(however only for release "blabla.exe" - for debug version it is OK!) :(
I've tried to use LoadLibraryEx(strHost, NULL, LOAD_LIBRARY_AS_DATAFILE) instead of LoadLibrary(strHost)
In this case i can get not NULL hInst for my release "blabla.exe", but LoadImage() returns NULL in this case (ok, in MSDN is written, that: You cannot use this handle with specialized resource management functions such as LoadBitmap, LoadCursor, LoadIcon, LoadImage... ).
The Question: what to do to let the icon be loaded in win98?
Thanks in advance,
Victor
I need to load some icons from external exe module.
I do so:
CString strHost = _T("blabla.exe")
HINSTANCE hInst = LoadLibrary(strHost);
if(hInst)
{
HICON hIcon = NULL;
pMenu->SetIconMode();
hIcon = (HICON)::LoadImage( hInst, MAKEINTRESOURCE (IDR_MAINFRAME), IMAGE_ICON, 16, 15, LR_DEFAULTCOLOR);
if(hIcon)
{
...
DestroyIcon(hIcon);
}
FreeLibrary(hInst );
}
It runs OK in NT/2000 but in Win98 I get hInst == NULL with GetLastError() == ERROR_BAD_FORMAT
(however only for release "blabla.exe" - for debug version it is OK!) :(
I've tried to use LoadLibraryEx(strHost, NULL, LOAD_LIBRARY_AS_DATAFILE) instead of LoadLibrary(strHost)
In this case i can get not NULL hInst for my release "blabla.exe", but LoadImage() returns NULL in this case (ok, in MSDN is written, that: You cannot use this handle with specialized resource management functions such as LoadBitmap, LoadCursor, LoadIcon, LoadImage... ).
The Question: what to do to let the icon be loaded in win98?
Thanks in advance,
Victor