Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

re loading an icon from a res dll

0 views
Skip to first unread message

Adrian Suri

unread,
Apr 23, 2008, 8:17:53 AM4/23/08
to
Hi

Can anyone give me any directions on how to load a dll from a resource
dll, which will form part of an external dll using watcom 1.7a

regards

Adrian

Lars Erdmann

unread,
Apr 23, 2008, 11:00:57 AM4/23/08
to
Hallo,

compiler should be irrelevant. Suppose your resource dll (precisely: the DLL
your icon resource is bound to) is named RESOURCE.DLL and the icon has an id
of ICON_ID:

CHAR szError[CCHMAXPATH];
APIRET rc = NO_ERROR;
HMODULE hmod = NULLHANDLE;
HPOINTER hpointer = NULLHANDLE;

rc = DosLoadModule(szError,sizeof(szError),"RESOURCE",&hmod); // if resource
DLL is on LIBPATH, otherwise specify full path and filename with file
extension
if (rc == NO_ERROR)
{
hpointer = WinLoadPointer(HWND_DESKTOP,hmod,ICON_ID);
if (!hpointer)
{
// use WinGetLastError to get the exact error condition
goto exit;
}

// use the pointer

WinDestroyPointer(hpointer);
}
else
{
// szError will give you additional info where the loading failure
originates from
}

exit:
if (hmod)
{
rc = DosFreeModule(hmod);
}

One thing that always confused me about OS/2 is if there is a difference
between a POINTER and an ICON. As far as I understand, there is none. So, if
you need a HICON instead of a HPOINTER you can safely cast HPOINTER to
HICON.

P.S: If you can be sure that the resource DLL is already loaded you can use
DosQueryModuleHandle instead of DosLoadModule.
P.P.S: I am not 100 % sure if the resource DLL has to be loaded for the time
you are making use of the icon. The code above assumes so.

"Adrian Suri" <adrian.su...@irusdev.co.uk> schrieb im Newsbeitrag
news:nOFPj.46657$_h7....@newsfe05.ams2...

Adrian Suri

unread,
May 9, 2008, 12:33:21 PM5/9/08
to
Hi Lars

Thanks for that finally got it working.....

Adrian

0 new messages