Results 1 to 7 of 7

Thread: [RESOLVED] OS Language

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2006
    Location
    Paris
    Posts
    301

    Resolved [RESOLVED] OS Language

    How can I detect the OS language of Windows using VB6 ?
    Thanks

  2. #2
    Hyperactive Member syntaxeater's Avatar
    Join Date
    Dec 2006
    Location
    Des Moines, IA
    Posts
    460

    Re: OS Language

    How can you detect the operating system language of Windows using VB6....

    Let's put this in medical terms.

    How can you detect the source of cancer using a spatula.

    While yes, I am being rude; I only hope the analogy gives you some perception about how wide your question is.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2006
    Location
    Paris
    Posts
    301

    Re: OS Language

    virtual rudeness is not a problem, just give an answer the next time.

  4. #4
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: OS Language

    What is OS Language?
    The Laguage as English, French, Japanese, etc ...
    Or the Laguage as Progrmaming Laguage?
    IIF(Post.Rate > 0 , , )

  5. #5
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: OS Language

    Code:
    Option Explicit
    
    Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
    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
    
    Private Const LOCALE_SCOUNTRY = &H6
    Private Const LOCALE_SLANGUAGE = &H2
    Private Const LOCALE_SENGLANGUAGE = &H1001
    Private Const MAX_BUF As Long = 260
         
    'get country name
    Private Function GetCountryName() As String
        Dim lID As Long, sBuf As String, lRet As Long
        lID = GetUserDefaultLCID
        sBuf = String$(MAX_BUF, Chr(0))
        lRet = GetLocaleInfo(lID, LOCALE_SCOUNTRY, sBuf, MAX_BUF)
        GetCountryName = Left$(sBuf, lRet - 1)
    End Function
    
    'get localized language
    Private Function GetLocaleLanguage() As String
        Dim lID As Long, sBuf As String, lRet As Long
        lID = GetUserDefaultLCID
        sBuf = String$(MAX_BUF, Chr(0))
        lRet = GetLocaleInfo(lID, LOCALE_SLANGUAGE, sBuf, MAX_BUF)
        GetLocaleLanguage = Left$(sBuf, lRet - 1)
    End Function
    
    'get language (in english)
    Private Function GetLocaleEngLanguage() As String
        Dim lID As Long, sBuf As String, lRet As Long
        lID = GetUserDefaultLCID
        sBuf = String$(MAX_BUF, Chr(0))
        lRet = GetLocaleInfo(lID, LOCALE_SENGLANGUAGE, sBuf, MAX_BUF)
        GetLocaleEngLanguage = Left$(sBuf, lRet - 1)
    End Function
    
    Private Sub Form_Load()
        Debug.Print "Country Name is: " & GetCountryName
        Debug.Print "Language (Localized): " & GetLocaleLanguage
        Debug.Print "Language (in English): " & GetLocaleEngLanguage
    End Sub
    Last edited by rory; Oct 7th, 2007 at 07:31 AM.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2006
    Location
    Paris
    Posts
    301

    Re: OS Language

    Thanks Rory you understood the question right away!

  7. #7
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: OS Language

    Quote Originally Posted by horazio
    Thanks Rory you understood the question right away!
    No problem, actually I put together code to get the OS Version at first (was a late night), then came back and noticed it was the Language you really wanted.

    So if you need the OS version also, let me know.

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