'DECLARATION API
Public Declare Function GetThreadLocale Lib "kernel32" () As Long
Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
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
'DECLARATION CONSTANTES
Public Const LOCALE_SCURRENCY As Long = &H14 'symbole monétaire local
Public Const LOCALE_SINTLSYMBOL As Long = &H15 'symbole monétaire international
Public Const LOCALE_SMONDECIMALSEP As Long = &H16 'séparateur monétaire décimal
Public Const LOCALE_SMONTHOUSANDSEP As Long = &H17 'séparateur monétaire des milliers
Public Const LOCALE_SMONGROUPING As Long = &H18 'groupement monétaire
Public Const LOCALE_ICURRDIGITS As Long = &H19 '# local monetary digits
Public Const LOCALE_IINTLCURRDIGITS As Long = &H1A '# intl monetary digits
Public Const LOCALE_ICURRENCY As Long = &H1B 'mode positif de la devise
Public Const LOCALE_INEGCURR As Long = &H1C 'mode négatif de la devise
Public Const LOCALE_IPOSSIGNPOSN As Long = &H52 'position du signe positif
Public Const LOCALE_INEGSIGNPOSN As Long = &H53 'position du signe négatif
Public Const LOCALE_IPOSSYMPRECEDES As Long = &H54 'mon sym precedes pos amt
Public Const LOCALE_IPOSSEPBYSPACE As Long = &H55 'mon sym sep by space from pos amt
Public Const LOCALE_INEGSYMPRECEDES As Long = &H56 'mon sym precedes neg amt
Public Const LOCALE_INEGSEPBYSPACE As Long = &H57 'mon sym sep by space from neg amt
Public Const LOCALE_SENGCURRNAME As Long = &H1007 'nom anglais de la devise
Public Const LOCALE_SNATIVECURRNAME As Long = &H1008 'nom natif de la devise
Sub Test()
Dim LCID As Long
LCID = GetSystemDefaultLCID()
MsgBox "Le séparateur décimal est: " & GetUserLocaleInfo(LCID, LOCALE_SMONDECIMALSEP)
End Sub
Public Function GetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType As Long) As String
Dim sReturn As String
Dim r As Long
'Appel de la fonction en passant la variable locale
'pour récupérer la taille du buffer du string dont nous avons besoin
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
'Si c'est OK..
If r Then
'On compléte le buffer avec des espaces
sReturn = Space$(r)
'et nouvel appel en passant la mémoire tampon
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
'Si Ok (r > 0)
If r Then
'r contient la taille de la chaîne de caractères
'comprenant la terminaison nulle
GetUserLocaleInfo = Left$(sReturn, r - 1)
End If
End If
End Function