Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Regional Settings


Message #1 by "Niall Hannon (ext. 772)" <Niall.Hannon@f...> on Thu, 22 Aug 2002 17:18:00 +0100
Option Explicit
Public Const LOCALE_SLANGUAGE       As Long = &H2  'localized name of
language
Public Const LOCALE_SABBREVLANGNAME As Long = &H3  'abbreviated language
name
Public Const LCID_INSTALLED         As Long = &H1  'installed locale ids
Public Const LCID_SUPPORTED         As Long = &H2  'supported locale ids
Public Const LCID_ALTERNATE_SORTS   As Long = &H4  'alternate sort locale
ids
Public Const LOCALE_USER_DEFAULT As Long = &H400

Public Enum LocaleCType
    LOCALE_SCURRENCY = &H14        '  local monetary symbol
    LOCALE_SDECIMAL = &HE         '  decimal separator
    LOCALE_SSHORTDATE = &H1F        ' short date format
    LOCALE_SDATE = &H1D             ' short date seperator
    LOCALE_STIMEFORMAT = &H1003
End Enum

Public Declare Function GetUserDefaultLCID% Lib "kernel32" ()

Public 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



Public Declare Sub CopyMemory Lib "kernel32" _
   Alias "RtlMoveMemory" _
  (Destination As Any, _
   Source As Any, _
   ByVal Length As Long)



Public Declare Function EnumSystemLocales Lib "kernel32" _
  Alias "EnumSystemLocalesA" _
  (ByVal lpLocaleEnumProc As Long, _
   ByVal dwFlags As Long) As Long


Public Function GetUserLocaleInfo(ByVal dwLocaleID As Long, _
                                  ByVal dwLCType As Long) As String

   Dim sReturn As String
   Dim nSize As Long

  'call the function passing the Locale type
  'variable to retrieve the required size of
  'the string buffer needed
   nSize = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))

  'if successful..
   If nSize Then

     'pad a buffer with spaces
      sReturn = Space$(nSize)

     'and call again passing the buffer
      nSize = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))

     'if successful (nSize > 0)
      If nSize Then

        'nSize holds the size of the string
        'including the terminating null
         GetUserLocaleInfo = Left$(sReturn, nSize - 1)

      End If

   End If

End Function


Public Function checkUserLocale() As Long
 Dim LCID As Long
   Dim strLanguage As String
   LCID = GetUserDefaultLCID()

End Function


Public Function GetLocaleSetting(ByVal LCType As LocaleCType) As String

    Dim sSymbol As String
    Dim l As Long
    Dim lpLCDataVar As String
    Dim iPos As Integer
    Dim lLocale As Long


    lLocale = GetUserDefaultLCID()
    l = GetLocaleInfo(lLocale, LCType, lpLCDataVar, 0)
    sSymbol = String$(l, 0)
    l = GetLocaleInfo(lLocale, LCType, sSymbol, l)
    iPos = InStr(sSymbol, Chr$(0))
    If iPos > 0 Then GetLocaleSetting = Left$(sSymbol, iPos - 1)

End Function

From the VB program,
call checkUserLocale method
CheckUserLocale returns LCID thro' which u can findout the regional
settings.

-Naveen


----- Original Message -----
From: "Niall Hannon (ext. 772)" <Niall.Hannon@f...>
To: "professional vb" <pro_vb@p...>
Sent: Thursday, August 22, 2002 9:48 PM
Subject: [pro_vb] Regional Settings


> Hi,
>
> I have been looking for the answer to this for a long time with no
success.
> How can I, through VB, check a users regional settings?
>
> Thanks
> Nialll
>
>
> **************************************************************************
> The information contained in this e-mail is confidential,
> may be privileged and is intended only for the use of the
> recipient named above. If you are not the intended
> recipient or a representative of the intended recipient,
> you have received this e-mail in error and must not copy,
> use or disclose the contents of this email to anybody
> else. If you have received this e-mail in error, please
> notify the sender immediately by return e-mail and
> permanently delete the copy you received. This email has
> been swept for computer viruses. However, you should
> carry out your own virus checks.
>
>
> Registered in Ireland, No. 205721. http://www.FINEOS.com
> **************************************************************************
>
>
>
> ---
> Visual C# - A Guide for VB6 Developers
> This book will make it easy to transfer your skills
> from Visual Basic 6 to C#, the language of choice
> of the .NET Framework.
> http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059
>


  Return to Index