Jump to content

DosQueryCtryInfo: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
Obtains country-dependent formatting information that resides in the country file.
Obtains country-dependent formatting information that resides in the country file.


==Syntax==
==Syntax==
<PRE>
DosQueryCtryInfo(cb, pcc, pci, pcbActual)
#define INCL_DOSNLS
#include <os2.h>


ULONG          cb;        /*  The length, in bytes, of the data area (pci) provided by the caller. */
PCOUNTRYCODE    pcc;        /*  Pointer to the COUNTRYCODE structure in which the country code and code page are identified. */
PCOUNTRYINFO    pci;        /*  A pointer to the COUNTRYINFO in which the country-dependent information is placed. */
PULONG          pcbActual;  /*  A pointer to a ULONG in which country-dependent data is returned. */
APIRET          ulrc;      /*  Return Code. */
ulrc = DosQueryCtryInfo(cb, pcc, pci, pcbActual);
</PRE>
==Parameters==
==Parameters==
; cb (ULONG) - input : The length, in bytes, of the data area (pci) provided by the caller.
;cb (ULONG) - input :The length, in bytes, of the data area (pci) provided by the caller.
 
:A length value of 40 bytes is sufficient.
A length value of 40 bytes is sufficient.  
;pcc (PCOUNTRYCODE) - input : Pointer to the COUNTRYCODE structure in which the country code and code page are identified.
:If country is set to 0, the country information for the default system country code is used.
:If codepage is set to 0, the country information for the current process code page of the caller is used.
:Refer to the [[COUNTRYCODE]] for a table of values for country code and code page identifier.
;pci (PCOUNTRYINFO) - output : A pointer to the COUNTRYINFO in which the country-dependent information is placed.
:The caller provides this data area. The input parameter cb specifies the size of this area.
:If this area is too small to hold all of the available information, then as much information as possible is provided in the available space (in the order in which the data would appear). If the amount of data returned is not enough to fill the memory area provided by the caller, then the memory that is unaltered by the available data is zeroed out. The format of the information returned in this buffer is as follows:
codepage is reserved, and must be set to 0.
;pcbActual (PULONG) - output : A pointer to a ULONG in which country-dependent data is returned.


; pcc (PCOUNTRYCODE) - input : Pointer to the COUNTRYCODE structure in which the country code and code page are identified.
If country is set to 0, the country information for the default system country code is used.
If codepage is set to 0, the country information for the current process code page of the caller is used.
Refer to the COUNTRYCODE for a table of values for country code and code page identifier.
; pci (PCOUNTRYINFO) - output : A pointer to the COUNTRYINFO in which the country-dependent information is placed.
The caller provides this data area. The input parameter cb specifies the size of this area.
If this area is too small to hold all of the available information, then as much information as possible is provided in the available space (in the order in which the data would appear). If the amount of data returned is not enough to fill the memory area provided by the caller, then the memory that is unaltered by the available data is zeroed out. The format of the information returned in this buffer is as follows:
    codepage is reserved, and must be set to 0.
; pcbActual (PULONG) - output : A pointer to a ULONG in which country-dependent data is returned.
==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosQueryCtryInfo returns one of the following values:
* 0  NO_ERROR
* 397  ERROR_NLS_OPEN_FAILED
* 398  ERROR_NLS_NO_CTRY_CODE
* 399  ERROR_NLS_TABLE_TRUNCATED
* 401  ERROR_NLS_TYPE_NOT_FOUND
* 476  ERROR_CODE_PAGE_NOT_FOUND


DosQueryCtryInfo returns one of the following values:
* 0    NO_ERROR
* 397        ERROR_NLS_OPEN_FAILED
* 398        ERROR_NLS_NO_CTRY_CODE
* 399        ERROR_NLS_TABLE_TRUNCATED
* 401        ERROR_NLS_TYPE_NOT_FOUND
* 476        ERROR_CODE_PAGE_NOT_FOUND
==Remarks==
==Remarks==
DosQueryCtryInfo obtains country-dependent formatting information that resides in the country file (the default name is COUNTRY.SYS).
DosQueryCtryInfo obtains country-dependent formatting information that resides in the country file (the default name is COUNTRY.SYS).


The country-dependent information returned corresponds to the system country code or selected country code, and to the process code page or selected code page.
The country-dependent information returned corresponds to the system country code or selected country code, and to the process code page or selected code page.
==Example Code==
==Example Code==
This example displays the current date in country-dependent format.
This example displays the current date in country-dependent format.
<PRE>
<code>
  #define INCL_DOSNLS        /* National Language Support values */
  #define INCL_DOSNLS        /* National Language Support values */
  #define INCL_DOSDATETIME  /* Date and time values */
  #define INCL_DOSDATETIME  /* Date and time values */
Line 61: Line 39:
  #include <os2.h>
  #include <os2.h>
  #include <stdio.h>
  #include <stdio.h>
 
  int main(VOID) {
  int main(VOID) {
 
  COUNTRYCODE  Country    = {0};  /* Country code info (0 = current country) */
  COUNTRYCODE  Country    = {0};  /* Country code info (0 = current country) */
  COUNTRYINFO  CtryInfo  = {0};  /* Buffer for country-specific information */
  COUNTRYINFO  CtryInfo  = {0};  /* Buffer for country-specific information */
Line 69: Line 47:
  DATETIME    DateTime  = {0};      /* Date and time information          */
  DATETIME    DateTime  = {0};      /* Date and time information          */
  APIRET      rc        = NO_ERROR;  /* Return code                        */
  APIRET      rc        = NO_ERROR;  /* Return code                        */
 
   rc = DosQueryCtryInfo(sizeof(CtryInfo), &Country,
   rc = DosQueryCtryInfo(sizeof(CtryInfo), &Country,
                           &CtryInfo, &ulInfoLen);
                           &CtryInfo, &ulInfoLen);
 
   if (rc != NO_ERROR) {
   if (rc != NO_ERROR) {
       printf("DosQueryCtryInfo error: return code = %u\n",rc);
       printf("DosQueryCtryInfo error: return code = %u\n",rc);
       return 1;
       return 1;
   }
   }
 
   rc = DosGetDateTime(&DateTime);  /* Retrieve the current date and time  */
   rc = DosGetDateTime(&DateTime);  /* Retrieve the current date and time  */
 
   if (rc != NO_ERROR) {
   if (rc != NO_ERROR) {
       printf ("DosGetDateTime error : return code = %u\n", rc);
       printf ("DosGetDateTime error : return code = %u\n", rc);
Line 85: Line 63:
   } else {
   } else {
       switch (CtryInfo.fsDateFmt) {
       switch (CtryInfo.fsDateFmt) {
 
       case(1):                                              /* dd/mm/yy */
       case(1):                                              /* dd/mm/yy */
       printf("Today is %d%s%d%s%d\n", DateTime.day, CtryInfo.szDateSeparator,
       printf("Today is %d%s%d%s%d\n", DateTime.day, CtryInfo.szDateSeparator,
               DateTime.month, CtryInfo.szDateSeparator, DateTime.year);
               DateTime.month, CtryInfo.szDateSeparator, DateTime.year);
         break;
         break;
 
       case(2):                                              /* yy/mm/dd */
       case(2):                                              /* yy/mm/dd */
       printf("Today is %d%s%d%s%d\n", DateTime.year, CtryInfo.szDateSeparator,
       printf("Today is %d%s%d%s%d\n", DateTime.year, CtryInfo.szDateSeparator,
               DateTime.month, CtryInfo.szDateSeparator, DateTime.day);
               DateTime.month, CtryInfo.szDateSeparator, DateTime.day);
         break;
         break;
 
       default:                                              /* mm/dd/yy */
       default:                                              /* mm/dd/yy */
       printf("Today is %d%s%d%s%d\n", DateTime.month, CtryInfo.szDateSeparator,
       printf("Today is %d%s%d%s%d\n", DateTime.month, CtryInfo.szDateSeparator,
               DateTime.day, CtryInfo.szDateSeparator, DateTime.year);
               DateTime.day, CtryInfo.szDateSeparator, DateTime.year);
         break;
         break;
 
       } /* endswitch */
       } /* endswitch */
   }
   }
     return NO_ERROR;
     return NO_ERROR;
  }
}
</code>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosMapCase|DosMapCase]]
*[[DosMapCase]]
* [[OS2 API:CPI:DosQueryCollate|DosQueryCollate]]
*[[DosQueryCollate]]
* [[OS2 API:CPI:DosQueryCp|DosQueryCp]]
*[[DosQueryCp]]
* [[OS2 API:CPI:DosQueryDBCSEnv|DosQueryDBCSEnv]]
*[[DosQueryDBCSEnv]]
* [[OS2 API:CPI:DosSetProcessCp|DosSetProcessCp]]
*[[DosSetProcessCp]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 17:30, 12 October 2018

Obtains country-dependent formatting information that resides in the country file.

Syntax

DosQueryCtryInfo(cb, pcc, pci, pcbActual)

Parameters

cb (ULONG) - input
The length, in bytes, of the data area (pci) provided by the caller.
A length value of 40 bytes is sufficient.
pcc (PCOUNTRYCODE) - input
Pointer to the COUNTRYCODE structure in which the country code and code page are identified.
If country is set to 0, the country information for the default system country code is used.
If codepage is set to 0, the country information for the current process code page of the caller is used.
Refer to the COUNTRYCODE for a table of values for country code and code page identifier.
pci (PCOUNTRYINFO) - output
A pointer to the COUNTRYINFO in which the country-dependent information is placed.
The caller provides this data area. The input parameter cb specifies the size of this area.
If this area is too small to hold all of the available information, then as much information as possible is provided in the available space (in the order in which the data would appear). If the amount of data returned is not enough to fill the memory area provided by the caller, then the memory that is unaltered by the available data is zeroed out. The format of the information returned in this buffer is as follows:
codepage is reserved, and must be set to 0. 
pcbActual (PULONG) - output
A pointer to a ULONG in which country-dependent data is returned.

Return Code

ulrc (APIRET) - returns
DosQueryCtryInfo returns one of the following values:
  • 0 NO_ERROR
  • 397 ERROR_NLS_OPEN_FAILED
  • 398 ERROR_NLS_NO_CTRY_CODE
  • 399 ERROR_NLS_TABLE_TRUNCATED
  • 401 ERROR_NLS_TYPE_NOT_FOUND
  • 476 ERROR_CODE_PAGE_NOT_FOUND

Remarks

DosQueryCtryInfo obtains country-dependent formatting information that resides in the country file (the default name is COUNTRY.SYS).

The country-dependent information returned corresponds to the system country code or selected country code, and to the process code page or selected code page.

Example Code

This example displays the current date in country-dependent format.

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

int main(VOID) {

COUNTRYCODE  Country    = {0};   /* Country code info (0 = current country) */
COUNTRYINFO  CtryInfo   = {0};   /* Buffer for country-specific information */
ULONG        ulInfoLen  = 0;
DATETIME     DateTime   = {0};       /* Date and time information           */
APIRET       rc         = NO_ERROR;  /* Return code                         */

  rc = DosQueryCtryInfo(sizeof(CtryInfo), &Country,
                         &CtryInfo, &ulInfoLen);

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

  rc = DosGetDateTime(&DateTime);  /* Retrieve the current date and time  */

  if (rc != NO_ERROR) {
     printf ("DosGetDateTime error : return code = %u\n", rc);
     return 1;
  } else {
     switch (CtryInfo.fsDateFmt) {

     case(1):                                               /* dd/mm/yy */
     printf("Today is %d%s%d%s%d\n", DateTime.day, CtryInfo.szDateSeparator,
             DateTime.month, CtryInfo.szDateSeparator, DateTime.year);
       break;

     case(2):                                               /* yy/mm/dd */
     printf("Today is %d%s%d%s%d\n", DateTime.year, CtryInfo.szDateSeparator,
             DateTime.month, CtryInfo.szDateSeparator, DateTime.day);
       break;

     default:                                               /* mm/dd/yy */
     printf("Today is %d%s%d%s%d\n", DateTime.month, CtryInfo.szDateSeparator,
             DateTime.day, CtryInfo.szDateSeparator, DateTime.year);
       break;

      } /* endswitch */
  }
    return NO_ERROR;
}

Related Functions