Announcement

Collapse
No announcement yet.

country code in win32 by WIN.INI?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • country code in win32 by WIN.INI?

    doing a search in these forums on "country code", i find this url:
    it contains lance's answer to my earlier question: "how to determine a country code in 16-bit windows?". such as: usa=1, canada=2, the netherlands=31, etc.

    according to lance you should retrieve it by reading win.ini, using the getprivateprofilestring api-call. is this the only way and is it valid in win32 too?

    actually, i refuse to believe that such an important piece of information - set by control panel's "regional settings" - must be read from an unprotected ini-file, since microsoft is advocating the use of the registry so strongly.

    does anyone know an (undocumented) api-call to get the country settings?

    thanks,
    egbert

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    Locale information may be found under the registry key HKEY_CURRENT_USER\Control Panel\International.

    Actually, Microsoft was advocating the use of the registry. They've apparently come to realize that a bloated, readily corruptible centralized registry is not such a fine thing after all. Microsoft is now recommending that private .INI files should be used instead!

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment


    • #3
      Code:
      #Compile Exe
      #Register None
      #Dim All
      #Include "Win32Api.Inc"
      Function GetLocale (Id As Long) As String
        Static Str As Asciiz * 256, ll As Long
        ll = GetLocaleInfo(%LOCALE_SYSTEM_DEFAULT, Id, Str, 255)
        If ll > 0 Then Function = Str
      End Function
      Function PbMain()
        MsgBox GetLocale (%LOCALE_SCOUNTRY)
        MsgBox GetLocale (%LOCALE_ICOUNTRY)
        MsgBox GetLocale (%LOCALE_IDEFAULTCODEPAGE)
        MsgBox "&H" + GetLocale (%LOCALE_IDEFAULTLANGUAGE)
      End Function
      [This message has been edited by Semen Matusovski (edited April 14, 2000).]

      Comment


      • #4
        Thank you, Semen, for your code sample. It was for PBCC, after all, but it was no trouble to change the PRINT statements into a MsgBox statement.
        I must say, the official Win32 helpfile is not very clear on this point.

        Regards to you both and thanks,
        Egbert

        ------------------

        Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
        http://zijlema.basicguru.eu
        *** Opinions expressed here are not necessarily untrue ***

        Comment


        • #5
          Egbert --
          You can find very detail description in MSDN, which comes, for example, with Visual Basic 6 (I tested Win32APi.Inc - they lost many possible parameters, which are interesting for international users).
          About Unicode: I understood, why PB GetLocaleInfo returns ANSI -
          Alias "GetLocaleInfoA".
          So I corrected my sample and give MSDN information about parameters
          Function: http://msdn.microsoft.com/library/specs/S1CE8A.HTM
          LCType constants http://msdn.microsoft.com/library/specs/S1CE73.HTM

          [This message has been edited by Semen Matusovski (edited April 14, 2000).]

          Comment

          Working...
          X