Obtaining OS language

  • Thread starter Thread starter Max Potters
  • Start date Start date
M

Max Potters

Hello everyone,

I have tried to obtain the OS language of my computer using VBA, but no
success. Could anyone please help me with this problem? I know it can be
done by using WinAPI, though I dont know how

Thanking you all in advance

Max
 
I would like to know the OS language, not the operating system I am running
 
Private Declare Function GetThreadLocale Lib "kernel32" () As Long

Private Declare Function GetSystemDefaultLCID 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

Const LOCALE_SENGLANGUAGE As Long = &H1001 'English name of lang

Dim LCID As Long

'---------------------------------------------------------------------------
Public Function GetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType
As Long) _
As String
'---------------------------------------------------------------------------
Dim sReturn As String
Dim r As Long

r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))

'if successful..
If r Then
sReturn = Space$(r)
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
If r Then
GetUserLocaleInfo = Left$(sReturn, r - 1)
End If

End If

End Function

'---------------------------------------------------------------------------
Public Function LanguageName() As String
'---------------------------------------------------------------------------

LCID = GetSystemDefaultLCID()
LanguageName = GetUserLocaleInfo(LCID, LOCALE_SENGLANGUAGE)
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top