This example loads the dynamic link module "DISPLAY.DLL," gets a resource object from it, and then releases it.

#define INCL_DOSRESOURCES     /* Resource types */
#define INCL_DOSMODULEMGR     /* Module Manager values */
#define INCL_DOSERRORS        /* DOS error values */
#include <os2.h>
#include <stdio.h>

int main(VOID) {
UCHAR     LoadError[256] = "";         /* Area for Load failure information */
PSZ       ModuleName = "C:\\OS2\\DLL\\PMWP.DLL";  /* DLL with resources */
HMODULE   ModHandle  = NULLHANDLE;        /* Handle for module */
PVOID     ResPtr     = NULL;              /* Pointer to resource */
APIRET    rc         = NO_ERROR;          /* API return code */

 rc = DosLoadModule(LoadError,               /* Failure information buffer */
                    sizeof(LoadError),       /* Size of buffer             */
                    ModuleName,              /* Module to load             */
                    &ModHandle);             /* Module handle returned     */
 if (rc != NO_ERROR) {
    printf("DosLoadModule error: return code = %u\n", rc);
    return 1;
 }

 rc = DosGetResource(ModHandle,     /* Handle for DLL containing resources */
                     RT_POINTER,    /* Ask for  Pointer                    */
                     1L,            /*          with an ID of 1            */
                     &ResPtr);  /* Get back pointer                    */
 if (rc != NO_ERROR) {
    printf("DosGetResource error: return code = %u\n", rc);
    return 1;
 } else {
    printf("Resource pointer = 0x%x\n", ResPtr);
 } /* endif */

 rc = DosFreeResource(ResPtr);
 if (rc != NO_ERROR) {
    printf("DosFreeResource error: return code = %u\n", rc);
    return 1;
 }

return NO_ERROR;
}


[Back] [Next]