This example loads a string from RES.DLL using the resource handle from DosLoadModule.

#define INCL_WINWINDOWMGR       /* Window Manager Functions     */
#define INCL_DOSMODULEMGR       /* Module Manager Functions     */
#include <os2.h>
#define STRING_ID 1

LONG    lLength;        /* length of string                     */
HAB     hab;            /* anchor-block handle                  */
HMODULE hmodDLL;        /* Handle of resource module            */
ULONG   idString = STRING_ID; /* String identifier              */
LONG    lBufferMax = 10;/* Size of buffer                       */
char    pszString1[10]; /* first string                         */
CHAR    LoadError[100]; /* object name buffer for DosLoad       */
ULONG   rc;             /* return code                          */

/* obtain resource handle */
rc = DosLoadModule(LoadError, sizeof(LoadError), "RES.DLL",
                   &hmodDLL);

/* load string from resource */
if (rc == 0)
   lLength = WinLoadString(hab, hmodDLL, idString, lBufferMax,
                            pszString1);


[Back] [Next]