DosQueryMessageCP

From EDM2
Jump to: navigation, search

DosQueryMessageCP retrieves the message file list of code pages and language identifiers.

Syntax

DosQueryMessageCP(pb, cb, pszFilename, cbBuf)

Parameters

pb (PCHAR) - output
Pointer to the caller's buffer area.
This buffer area is where the system returns the requested message file list of code pages and language identifiers.
cb (ULONG) - input
The length, in bytes, of pb.
pszFilename (PSZ) - input
The file specification of the message file.
The drive designation and path are optional. This specifies a file that was previously prepared by the MKMSGF utility program.
cbBuf (PULONG) - output
Pointer to the ULONG that receives the actual length, in bytes, of the returned data.
ulrc (APIRET) - returns
Return Code.
DosQueryMessageCP returns one of the following values:
0 NO_ERROR
2 ERROR_FILE_NOT_FOUND
206 ERROR_FILENAME_EXCED_RANGE
318 ERROR_MR_UN_ACC_MSGF
319 ERROR_MR_INV_MSGF_FORMAT
321 ERROR_MR_UN_PERFORM

Remarks

The system returns the requested message file list of code pages and language identifiers in the caller's buffer (pb). It has the following format:

Length Field
USHORT Code page count (N)
USHORT Code page identifier. This field occurs N times, once per code page.
ULONG Language identifier

This data structure is repeated for each subfile within the specified message file.

The code page identifier can have the values specified in COUNTRYCODE.

The language identifier is a ULONG. The low-order word identifies a language family, and the high-order word identifies a specific version of that language (a sublanguage).

The language and sublanguage identifier values 0 through 255 are reserved for system use. The values 256 through 511 are reserved for application use.

The MKMSGF utility program performs range checking on the language and sublanguage identifier values. The value 0 means a null or unspecified language or sublanguage. Only the values defined in the following table are valid below 256. Any values from 256 through 511 are valid. Any identifier value greater than 511 is invalid.

The following table shows the valid language and sublanguage identifier values. Column 1 is the language family identifier, and column 2 is the sublanguage identifier. Column 3 shows the language, and column 4 shows the principal country for this language.

Family Subl. Language Principal country
0 0 null null
1 1 Arabic Arab countries
2 1 Bulgarian Bulgaria
3 2 Spanish Spain
3 3 Spanish Mexican Mexico
4 1 Traditional Chinese Republic of China
4 2 Simplified Chinese People's Republic of China
5 1 Czech Czechoslovakia
6 1 Danish Denmark
7 1 German Germany
7 2 Swiss German Switzerland
8 1 Greek Greece
9 1 U.K. English United Kingdom
9 2 U.S. English United States
10 1 Finnish Finland
11 1 French France
11 2 Belgian French Belgium
11 3 Canadian French Canada
11 4 Swiss French Switzerland
12 1 Hebrew Israel
13 1 Hungarian Hungary
14 1 Icelandic Iceland
15 1 Italian Italy
15 2 Swiss Italian Switzerland
16 1 Japanese Japan
17 1 Korean Korea
18 1 Dutch Netherlands
18 2 Belgian Dutch Belgium
19 1 Norwegian - Bokmal Norway
19 2 Norwegian - Nynorsk Norway
20 1 Polish Poland
21 1 Portuguese Portugal
22 2 Brazilian Portuguese Brazil
23 1 Rhaeto-Romanic Switzerland
24 1 Serbo-Croatian (Cyrillic) Yugoslavia
24 2 Serbo-Croatian (Latin) Yugoslavia
25 1 Slovakian Czechoslovakia
26 1 Albanian Albania
27 1 Swedish Sweden
28 1 Thai Thailand
29 1 Turkish Turkey
30 1 Urdu Pakistan
31 1 Russian U.S.S.R.
32 1 Catalan Spain

Example Code

This example queries the number of code pages and the first code page and language identifier from the file "SAMPLE.MSG". The result of the query has the format specified be the _MYCPINFO structure.

#define INCL_DOSMISC    /* Miscellaneous values */
#define INCL_DOSERRORS  /* DOS Error values */
#include <os2.h>
#include <stdio.h>

int main(VOID) {

typedef struct _MYCPINFO
 {  USHORT       cCP;          /* Number of code pages */
    USHORT       CP1;          /* First code page      */
    ULONG        dtype;
 } MYCPINFO;

UCHAR     uchBuffer[20] = {0};            /* Buffer for the returned list */
MYCPINFO  CPinfo         = {0};           /* Pointer to buffer */
ULONG     ulDataLen      = 0;             /* Length of data returned */
APIRET    rc             = NO_ERROR;      /* Return code */

 rc = DosQueryMessageCP( (PUCHAR) &CPinfo,
                         sizeof(MYCPINFO),
                         "SAMPLE.MSG",
                         &ulDataLen );

 if (rc != NO_ERROR) {
      printf("DosQueryMessageCP error: return code = %u\n", rc);
      return 1;
 } else {
      printf("SAMPLE.MSG:  %u Code Page(s) - Code Page 1 = %u.\n",
                                        CPinfo.cCP, CPinfo.CP1);
 } /* endif */

return NO_ERROR;
}

Related Functions