getctry.pas 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. program GetCountryInfo;
  2. {$IFNDEF OS2}
  3. Sorry, this code is for OS/2 only...
  4. {$ENDIF}
  5. uses
  6. {$IFDEF FPC}
  7. DosCalls;
  8. {$ELSE}
  9. Os2Def,
  10. {$IFDEF SPEED}
  11. BseDos;
  12. {$ELSE}
  13. DosProcs, DosTypes;
  14. {$ENDIF}
  15. {$ENDIF}
  16. type
  17. cardinal = longint;
  18. {$IFDEF FPC}
  19. const
  20. NO_ERROR = 0;
  21. {$ENDIF}
  22. var
  23. {$IFDEF VER70} (* patched Borland Pascal *)
  24. Country: TCountryCode;
  25. CtryInfo: TCountryInfo;
  26. Size: longint;
  27. {$ELSE}
  28. Country: COUNTRYCODE; (* Country code info (0 = current country) *)
  29. CtryInfo: COUNTRYINFO; (* Buffer for country-specific information *)
  30. Size: cardinal; (* Real size of returned data *)
  31. {$ENDIF}
  32. W: word;
  33. begin
  34. WriteLn;
  35. Size := 0;
  36. FillChar (Country, SizeOf (Country), 0);
  37. FillChar (CtryInfo, SizeOf (CtryInfo), 0);
  38. W :=
  39. {$IFDEF VER70}
  40. DosGetCtryInfo
  41. {$ELSE}
  42. DosQueryCtryInfo
  43. {$ENDIF}
  44. (SizeOf (CtryInfo), Country, CtryInfo, Size);
  45. if (W <> NO_ERROR) then
  46. begin
  47. WriteLn ('DosQueryCtryInfo error: return code = ', W);
  48. Halt (1);
  49. end;
  50. WriteLn ('Code of the country is ', CtryInfo.Country,
  51. ', current codepage is ', CtryInfo.CodePage);
  52. end.