DosQueryCp

From EDM2
Jump to: navigation, search

Allows a process to query its current process code page and the prepared system code pages.

Syntax

DosQueryCp(cb, arCP, pcCP)

Parameters

cb (ULONG) - input 
The length, in bytes, of arCP.
arCP (PULONG) - output 
The returned data list.
The first ULONG is the current code page identifier of the calling process.
If one or two code pages have been prepared for the system, then the second ULONG is the first prepared code page, and the third ULONG is the second prepared code page.
If the data length is less than the number of bytes needed to return all of the prepared system code pages, then the returned list is truncated.
The code page identifiers have the values described in the following list.
pcCP (PULONG) - output 
The length, in bytes, of the returned data.

Return Code

ulrc (APIRET) - returns
DosQueryCp returns one of the following values:
  • 0 NO_ERROR
  • 473 ERROR_CPLIST_TOO_SMALL
  • 474 ERROR_CP_NOT_MOVED

Remarks

The process code page identifier previously set by DosSetProcessCp or inherited by the process is returned to the caller. An input list size of two bytes returns only the current process code page identifier. If no code pages have been prepared with the CODEPAGE command, a length of two and a current code page identifier value of zero are returned.

Note: If no CODEPAGE= statement exists in CONFIG.SYS, the operating system uses the first codepage that it finds in the COUNTRY.SYS file for that country.

The system code page identifiers are returned to the caller in the same order as they appear in the CODEPAGE command. The code page identifiers are returned in the following order:

  • The current code page of the process (one of the system code pages).
  • The primary (default) system code page.
  • The secondary system code page, if specified.

Example Code

This example gets the current code page and up to three other prepared code pages.

#define INCL_DOSNLS     /* National Language Support values */
#define INCL_DOSERRORS  /* DOS error values                 */
#include <os2.h>
#include <stdio.h>

int main(VOID) {
   ULONG  aulCpList[8]  = {0},                /* Code page list        */
          ulBufSize     = 8 * sizeof(ULONG),  /* Size of output list   */
          ulListSize    = 0,                  /* Size of list returned */
          indx          = 0;                  /* Loop index            */
   APIRET rc            = NO_ERROR;           /* Return code           */

   rc = DosQueryCp(ulBufSize,      /* Length of output code page list  */
                   aulCpList,      /* List of code pages               */
                   &ulListSize);   /* Length of list returned          */

   if (rc != NO_ERROR) {
      printf("DosQueryCp error: return code = %u\n",rc);
      return 1;
   } else {
      for (indx=0; indx < ulListSize/sizeof(ULONG); indx++)
         printf ("aulCpList[%u] = %u\n", indx, aulCpList[indx]);
   }

   return NO_ERROR;
}

Related Functions