Results 1 to 3 of 3

Thread: How can I detect the OS language?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    How can I detect the OS language?

    Is there any possibility to detect on program start what
    language is used on the running OS? (API...)

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    You can get all kinds of stuff from the regional settings. Here is an example. Play with it....
    VB Code:
    1. Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
    2. Private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
    3. Private Declare Function GetUserDefaultLCID% Lib "kernel32" ()
    4.  
    5. Private Const LOCALE_ICENTURY = &H24
    6. Private Const LOCALE_ICOUNTRY = &H5
    7. Private Const LOCALE_ICURRDIGITS = &H19
    8. Private Const LOCALE_ICURRENCY = &H1B
    9. Private Const LOCALE_IDATE = &H21
    10. Private Const LOCALE_IDAYLZERO = &H26
    11. Private Const LOCALE_IDEFAULTCODEPAGE = &HB
    12. Private Const LOCALE_IDEFAULTCOUNTRY = &HA
    13. Private Const LOCALE_IDEFAULTLANGUAGE = &H9
    14. Private Const LOCALE_IDIGITS = &H11
    15. Private Const LOCALE_IINTLCURRDIGITS = &H1A
    16. Private Const LOCALE_ILANGUAGE = &H1
    17. Private Const LOCALE_ILDATE = &H22
    18. Private Const LOCALE_ILZERO = &H12
    19. Private Const LOCALE_IMEASURE = &HD
    20. Private Const LOCALE_IMONLZERO = &H27
    21. Private Const LOCALE_INEGCURR = &H1C
    22. Private Const LOCALE_INEGSEPBYSPACE = &H57
    23. Private Const LOCALE_INEGSIGNPOSN = &H53
    24. Private Const LOCALE_INEGSYMPRECEDES = &H56
    25. Private Const LOCALE_IPOSSEPBYSPACE = &H55
    26. Private Const LOCALE_IPOSSIGNPOSN = &H52
    27. Private Const LOCALE_IPOSSYMPRECEDES = &H54
    28. Private Const LOCALE_ITIME = &H23
    29. Private Const LOCALE_ITLZERO = &H25
    30. Private Const LOCALE_NOUSEROVERRIDE = &H80000000
    31. Private Const LOCALE_S1159 = &H28
    32. Private Const LOCALE_S2359 = &H29
    33. Private Const LOCALE_SABBREVCTRYNAME = &H7
    34. Private Const LOCALE_SABBREVDAYNAME1 = &H31
    35. Private Const LOCALE_SABBREVDAYNAME2 = &H32
    36. Private Const LOCALE_SABBREVDAYNAME3 = &H33
    37. Private Const LOCALE_SABBREVDAYNAME4 = &H34
    38. Private Const LOCALE_SABBREVDAYNAME5 = &H35
    39. Private Const LOCALE_SABBREVDAYNAME6 = &H36
    40. Private Const LOCALE_SABBREVDAYNAME7 = &H37
    41. Private Const LOCALE_SABBREVLANGNAME = &H3
    42. Private Const LOCALE_SABBREVMONTHNAME1 = &H44
    43. Private Const LOCALE_SCOUNTRY = &H6
    44. Private Const LOCALE_SCURRENCY = &H14
    45. Private Const LOCALE_SDATE = &H1D
    46. Private Const LOCALE_SDAYNAME1 = &H2A
    47. Private Const LOCALE_SDAYNAME2 = &H2B
    48. Private Const LOCALE_SDAYNAME3 = &H2C
    49. Private Const LOCALE_SDAYNAME4 = &H2D
    50. Private Const LOCALE_SDAYNAME5 = &H2E
    51. Private Const LOCALE_SDAYNAME6 = &H2F
    52. Private Const LOCALE_SDAYNAME7 = &H30
    53. Private Const LOCALE_SDECIMAL = &HE
    54. Private Const LOCALE_SENGCOUNTRY = &H1002
    55. Private Const LOCALE_SENGLANGUAGE = &H1001
    56. Private Const LOCALE_SGROUPING = &H10
    57. Private Const LOCALE_SINTLSYMBOL = &H15
    58. Private Const LOCALE_SLANGUAGE = &H2
    59. Private Const LOCALE_SLIST = &HC
    60. Private Const LOCALE_SLONGDATE = &H20
    61. Private Const LOCALE_SMONDECIMALSEP = &H16
    62. Private Const LOCALE_SMONGROUPING = &H18
    63. Private Const LOCALE_SMONTHNAME1 = &H38
    64. Private Const LOCALE_SMONTHNAME10 = &H41
    65. Private Const LOCALE_SMONTHNAME11 = &H42
    66. Private Const LOCALE_SMONTHNAME12 = &H43
    67. Private Const LOCALE_SMONTHNAME2 = &H39
    68. Private Const LOCALE_SMONTHNAME3 = &H3A
    69. Private Const LOCALE_SMONTHNAME4 = &H3B
    70. Private Const LOCALE_SMONTHNAME5 = &H3C
    71. Private Const LOCALE_SMONTHNAME6 = &H3D
    72. Private Const LOCALE_SMONTHNAME7 = &H3E
    73. Private Const LOCALE_SMONTHNAME8 = &H3F
    74. Private Const LOCALE_SMONTHNAME9 = &H40
    75. Private Const LOCALE_SMONTHOUSANDSEP = &H17
    76. Private Const LOCALE_SNATIVECTRYNAME = &H8
    77. Private Const LOCALE_SNATIVEDIGITS = &H13
    78. Private Const LOCALE_SNATIVELANGNAME = &H4
    79. Private Const LOCALE_SNEGATIVESIGN = &H51
    80. Private Const LOCALE_SPOSITIVESIGN = &H50
    81. Private Const LOCALE_SSHORTDATE = &H1F
    82. Private Const LOCALE_STHOUSAND = &HF
    83. Private Const LOCALE_STIME = &H1E
    84. Private Const LOCALE_STIMEFORMAT = &H1003
    85.  
    86. Private Sub GetRegionalSettings() ' Retrieve the regional setting
    87.  
    88.       Dim Symbol As String
    89.       Dim iRet1 As Long
    90.       Dim iRet2 As Long
    91.       Dim lpLCDataVar As String
    92.       Dim Pos As Integer
    93.       Dim Locale As Long
    94.      
    95.       Locale = GetUserDefaultLCID()
    96.  
    97. 'LOCALE_SDATE is the constant for the date separator
    98. 'as stated in declarations
    99. 'for any other locale setting just change the constant
    100.  
    101. 'Function can also be re-written to take the
    102. 'locale symbol being requested as a parameter
    103.      
    104.       iRet1 = GetLocaleInfo(Locale, LOCALE_SDATE, _
    105.       lpLCDataVar, 0)
    106.       Symbol = String$(iRet1, 0)
    107.      
    108.       iRet2 = GetLocaleInfo(Locale, LOCALE_SDATE, Symbol, iRet1)
    109.       Pos = InStr(Symbol, Chr$(0))
    110.       If Pos > 0 Then
    111.            Symbol = Left$(Symbol, Pos - 1)
    112.            MsgBox "Regional Setting = " + Symbol
    113.       End If
    114.  
    115. End Sub
    116.  
    117. Private Sub SetRegionalSettings() 'Change the regional setting
    118.  
    119.       Dim Symbol As String
    120.       Dim iRet As Long
    121.       Dim Locale As Long
    122.      
    123. 'LOCALE_SDATE is the constant for the date separator
    124. 'as stated in declarations
    125. 'for any other locale setting just change the constant
    126.  
    127. 'Function can also be re-written to take the
    128. 'locale information being set as a parameter
    129.  
    130.       Locale = GetUserDefaultLCID() 'Get user Locale ID
    131.       Symbol = "-" 'New character for the locale
    132.       iRet = SetLocaleInfo(Locale, LOCALE_SDATE, Symbol)
    133.      
    134. End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395
    more then i asked for

    but yes realy great

    many thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width