This example compares two strings using the same code page: the first string is loaded from a resource DLL, while the second is created by the application.

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

ULONG   ulResult;       /* comparison result                    */
HAB     hab;            /* anchor-block handle                  */
ULONG   idCodepage=437; /* Code page identity of both strings   */
ULONG   idCountryCode=1;/* Country code                         */
char    pszString1[10]; /* first string                         */
char    pszString2[10]; /* second string                        */
LONG    lLength;        /* length of string                     */
ULONG   idString = STRING_ID; /* String identifier              */
LONG    lBufferMax = 10;/* Size of buffer                       */
HMODULE hmodDLL;        /* Handle of the module which contains
                           the help table and help subtable
                           resources.                           */
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);

/* compare strings */
if (lLength > 0)
   {
   /* set second string */
   strcpy(pszString2,"Compare");

   ulResult = WinCompareStrings(hab, idCodepage, idCountryCode,
                                pszString1, pszString2, 0);
   }


[Back] [Next]