Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[WD 12] API

6 réponses
Avatar
JeAn-PhI
bonjour

je cherche à récupérer les infos suivantes :

Panneau de config|Options régionales et linguistiques|bouton
Personnaliser|onglet Date| les valeurs des champs : "Quand une année
sur 2 chiffres est entrée, l'interpréter comme une année compris entre
:"

j'ai fait des recherches et je suis tombé sur GetLocaleInfoA de
kernel32

- 1°) est ce la bonne api à utliser ?
- 2°) si oui alors comment le faire car j'ai beau tout essayer et je
n'y parviens pas
- 3°) comment récupérer les valeurs des constantes pour les api ?

--
Cordialement JeAn-PhI

6 réponses

Avatar
Thumain Th.
Le Mon, 03 Nov 2008 16:33:00 +0100, JeAn-PhI a écrit:

bonjour

je cherche à récupérer les infos suivantes :

Panneau de config|Options régionales et linguistiques|bouton
Personnaliser|onglet Date| les valeurs des champs : "Quand une année sur
2 chiffres est entrée, l'interpréter comme une année compris entre :"

j'ai fait des recherches et je suis tombé sur GetLocaleInfoA de kernel32

- 1°) est ce la bonne api à utliser ?
- 2°) si oui alors comment le faire car j'ai beau tout essayer et je
n'y parviens pas
- 3°) comment récupérer les valeurs des constantes pour les api ?



Doc de l'API:

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

· Locale
[in] Specifies the locale to retrieve information for. This parameter can
be a locale identifier created by the MAKELCID macro, or one of the
following predefined values:
Value Description
LOCALE_SYSTEM_DEFAULT Default system locale.
LOCALE_USER_DEFAULT Default user locale.
LOCALE_NEUTRAL Default language-neutral locale.

· LCType
[in] Specifies one of the LCTYPE constants to indicate the type of
information to be retrieved.
All LCTYPE values are mutually exclusive, with the exception of
LOCALE_NOUSEROVERRIDE. An application may use the binary-OR operator to
combine LOCALE_NOUSEROVERRIDE with any other LCTYPE value. If passed such
an LCType value, the function bypasses user overrides, and returns the
system default value for the requested LCID.

· lpLCData
[out] Pointer to a buffer to receive the requested data.

· cchData
[in] Specifies the size, in characters, of the lpLCData buffer. If cchData
is zero, the function returns the number of characters required to hold
the information, and the buffer pointed to by lpLCData is not used.

Exemple VB:
Const LOCALE_USER_DEFAULT = &H400
Const LOCALE_SENGCOUNTRY = &H1002 ' English name of country
Const LOCALE_SENGLANGUAGE = &H1001 ' English name of language
Const LOCALE_SNATIVELANGNAME = &H4 ' native name of language
Const LOCALE_SNATIVECTRYNAME = &H8 ' native name of country
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 Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail:
MsgBox "You live in " & GetInfo(LOCALE_SENGCOUNTRY) & " (" &
GetInfo(LOCALE_SNATIVECTRYNAME) & ")," & vbCrLf & "and you speak " &
GetInfo(LOCALE_SENGLANGUAGE) & " (" & GetInfo(LOCALE_SNATIVELANGNAME) &
").", vbInformation
End Sub
Public Function GetInfo(ByVal lInfo As Long) As String
Dim Buffer As String, Ret As String
Buffer = String$(256, 0)
Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
If Ret > 0 Then
GetInfo = Left$(Buffer, Ret - 1)
Else
GetInfo = ""
End If
End Function

Cela semble bien être la bonne API , mais il manque à trouver la bonne
valeur de LCTYPE ?

--
TT
Avatar
patrice
"Thumain Th." a écrit dans le message de
news:
Le Mon, 03 Nov 2008 16:33:00 +0100, JeAn-PhI a écrit:

Cela semble bien être la bonne API , mais il manque à trouver la bonne
valeur de LCTYPE ?




//
// The following LCTypes are mutually exclusive in that they may NOT
// be used in combination with each other.
//
#define LOCALE_ILANGUAGE 0x00000001 // language id
#define LOCALE_SLANGUAGE 0x00000002 // localized name of
language
#define LOCALE_SENGLANGUAGE 0x00001001 // English name of
language
#define LOCALE_SABBREVLANGNAME 0x00000003 // abbreviated language
name
#define LOCALE_SNATIVELANGNAME 0x00000004 // native name of
language

#define LOCALE_ICOUNTRY 0x00000005 // country code
#define LOCALE_SCOUNTRY 0x00000006 // localized name of
country
#define LOCALE_SENGCOUNTRY 0x00001002 // English name of
country
#define LOCALE_SABBREVCTRYNAME 0x00000007 // abbreviated country
name
#define LOCALE_SNATIVECTRYNAME 0x00000008 // native name of country

#define LOCALE_IDEFAULTLANGUAGE 0x00000009 // default language id
#define LOCALE_IDEFAULTCOUNTRY 0x0000000A // default country code
#define LOCALE_IDEFAULTCODEPAGE 0x0000000B // default oem code page
#define LOCALE_IDEFAULTANSICODEPAGE 0x00001004 // default ansi code page
#define LOCALE_IDEFAULTMACCODEPAGE 0x00001011 // default mac code page

#define LOCALE_SLIST 0x0000000C // list item separator
#define LOCALE_IMEASURE 0x0000000D // 0 = metric, 1 = US

#define LOCALE_SDECIMAL 0x0000000E // decimal separator
#define LOCALE_STHOUSAND 0x0000000F // thousand separator
#define LOCALE_SGROUPING 0x00000010 // digit grouping
#define LOCALE_IDIGITS 0x00000011 // number of fractional
digits
#define LOCALE_ILZERO 0x00000012 // leading zeros for
decimal
#define LOCALE_INEGNUMBER 0x00001010 // negative number mode
#define LOCALE_SNATIVEDIGITS 0x00000013 // native ascii 0-9

#define LOCALE_SCURRENCY 0x00000014 // local monetary symbol
#define LOCALE_SINTLSYMBOL 0x00000015 // intl monetary symbol
#define LOCALE_SMONDECIMALSEP 0x00000016 // monetary decimal
separator
#define LOCALE_SMONTHOUSANDSEP 0x00000017 // monetary thousand
separator
#define LOCALE_SMONGROUPING 0x00000018 // monetary grouping
#define LOCALE_ICURRDIGITS 0x00000019 // # local monetary
digits
#define LOCALE_IINTLCURRDIGITS 0x0000001A // # intl monetary digits
#define LOCALE_ICURRENCY 0x0000001B // positive currency mode
#define LOCALE_INEGCURR 0x0000001C // negative currency mode

#define LOCALE_SDATE 0x0000001D // date separator
#define LOCALE_STIME 0x0000001E // time separator
#define LOCALE_SSHORTDATE 0x0000001F // short date format
string
#define LOCALE_SLONGDATE 0x00000020 // long date format
string
#define LOCALE_STIMEFORMAT 0x00001003 // time format string
#define LOCALE_IDATE 0x00000021 // short date format
ordering
#define LOCALE_ILDATE 0x00000022 // long date format
ordering
#define LOCALE_ITIME 0x00000023 // time format specifier
#define LOCALE_ITIMEMARKPOSN 0x00001005 // time marker position
#define LOCALE_ICENTURY 0x00000024 // century format
specifier (short date)
#define LOCALE_ITLZERO 0x00000025 // leading zeros in time
field
#define LOCALE_IDAYLZERO 0x00000026 // leading zeros in day
field (short date)
#define LOCALE_IMONLZERO 0x00000027 // leading zeros in month
field (short date)
#define LOCALE_S1159 0x00000028 // AM designator
#define LOCALE_S2359 0x00000029 // PM designator

#define LOCALE_ICALENDARTYPE 0x00001009 // type of calendar
specifier
#define LOCALE_IOPTIONALCALENDAR 0x0000100B // additional calendar
types specifier
#define LOCALE_IFIRSTDAYOFWEEK 0x0000100C // first day of week
specifier
#define LOCALE_IFIRSTWEEKOFYEAR 0x0000100D // first week of year
specifier

#define LOCALE_SDAYNAME1 0x0000002A // long name for Monday
#define LOCALE_SDAYNAME2 0x0000002B // long name for Tuesday
#define LOCALE_SDAYNAME3 0x0000002C // long name for
Wednesday
#define LOCALE_SDAYNAME4 0x0000002D // long name for Thursday
#define LOCALE_SDAYNAME5 0x0000002E // long name for Friday
#define LOCALE_SDAYNAME6 0x0000002F // long name for Saturday
#define LOCALE_SDAYNAME7 0x00000030 // long name for Sunday
#define LOCALE_SABBREVDAYNAME1 0x00000031 // abbreviated name for
Monday
#define LOCALE_SABBREVDAYNAME2 0x00000032 // abbreviated name for
Tuesday
#define LOCALE_SABBREVDAYNAME3 0x00000033 // abbreviated name for
Wednesday
#define LOCALE_SABBREVDAYNAME4 0x00000034 // abbreviated name for
Thursday
#define LOCALE_SABBREVDAYNAME5 0x00000035 // abbreviated name for
Friday
#define LOCALE_SABBREVDAYNAME6 0x00000036 // abbreviated name for
Saturday
#define LOCALE_SABBREVDAYNAME7 0x00000037 // abbreviated name for
Sunday
#define LOCALE_SMONTHNAME1 0x00000038 // long name for January
#define LOCALE_SMONTHNAME2 0x00000039 // long name for February
#define LOCALE_SMONTHNAME3 0x0000003A // long name for March
#define LOCALE_SMONTHNAME4 0x0000003B // long name for April
#define LOCALE_SMONTHNAME5 0x0000003C // long name for May
#define LOCALE_SMONTHNAME6 0x0000003D // long name for June
#define LOCALE_SMONTHNAME7 0x0000003E // long name for July
#define LOCALE_SMONTHNAME8 0x0000003F // long name for August
#define LOCALE_SMONTHNAME9 0x00000040 // long name for
September
#define LOCALE_SMONTHNAME10 0x00000041 // long name for October
#define LOCALE_SMONTHNAME11 0x00000042 // long name for November
#define LOCALE_SMONTHNAME12 0x00000043 // long name for December
#define LOCALE_SMONTHNAME13 0x0000100E // long name for 13th
month (if exists)
#define LOCALE_SABBREVMONTHNAME1 0x00000044 // abbreviated name for
January
#define LOCALE_SABBREVMONTHNAME2 0x00000045 // abbreviated name for
February
#define LOCALE_SABBREVMONTHNAME3 0x00000046 // abbreviated name for
March
#define LOCALE_SABBREVMONTHNAME4 0x00000047 // abbreviated name for
April
#define LOCALE_SABBREVMONTHNAME5 0x00000048 // abbreviated name for
May
#define LOCALE_SABBREVMONTHNAME6 0x00000049 // abbreviated name for
June
#define LOCALE_SABBREVMONTHNAME7 0x0000004A // abbreviated name for
July
#define LOCALE_SABBREVMONTHNAME8 0x0000004B // abbreviated name for
August
#define LOCALE_SABBREVMONTHNAME9 0x0000004C // abbreviated name for
September
#define LOCALE_SABBREVMONTHNAME10 0x0000004D // abbreviated name for
October
#define LOCALE_SABBREVMONTHNAME11 0x0000004E // abbreviated name for
November
#define LOCALE_SABBREVMONTHNAME12 0x0000004F // abbreviated name for
December
#define LOCALE_SABBREVMONTHNAME13 0x0000100F // abbreviated name for
13th month (if exists)

#define LOCALE_SPOSITIVESIGN 0x00000050 // positive sign
#define LOCALE_SNEGATIVESIGN 0x00000051 // negative sign
#define LOCALE_IPOSSIGNPOSN 0x00000052 // positive sign position
#define LOCALE_INEGSIGNPOSN 0x00000053 // negative sign position
#define LOCALE_IPOSSYMPRECEDES 0x00000054 // mon sym precedes pos
amt
#define LOCALE_IPOSSEPBYSPACE 0x00000055 // mon sym sep by space
from pos amt
#define LOCALE_INEGSYMPRECEDES 0x00000056 // mon sym precedes neg
amt
#define LOCALE_INEGSEPBYSPACE 0x00000057 // mon sym sep by space
from neg amt

#if(WINVER >= 0x0400)
#define LOCALE_FONTSIGNATURE 0x00000058 // font signature
#define LOCALE_SISO639LANGNAME 0x00000059 // ISO abbreviated
language name
#define LOCALE_SISO3166CTRYNAME 0x0000005A // ISO abbreviated
country name
#endif /* WINVER >= 0x0400 */

#if(WINVER >= 0x0500)
#define LOCALE_IDEFAULTEBCDICCODEPAGE 0x00001012 // default ebcdic code
page
#define LOCALE_IPAPERSIZE 0x0000100A // 0 = letter, 1 = a4, 2
= legal, 3 = a3
#define LOCALE_SENGCURRNAME 0x00001007 // english name of
currency
#define LOCALE_SNATIVECURRNAME 0x00001008 // native name of
currency
#define LOCALE_SYEARMONTH 0x00001006 // year month format
string
#define LOCALE_SSORTNAME 0x00001013 // sort name
#define LOCALE_IDIGITSUBSTITUTION 0x00001014 // 0 = none, 1 = context,
2 = native digit
#endif /* WINVER >= 0x0500 */
Avatar
JeAn-PhI
Après mûre réflexion, Thumain Th. a écrit :
Le Mon, 03 Nov 2008 16:33:00 +0100, JeAn-PhI a écrit:

bonjour

je cherche à récupérer les infos suivantes :

Panneau de config|Options régionales et linguistiques|bouton
Personnaliser|onglet Date| les valeurs des champs : "Quand une année sur 2
chiffres est entrée, l'interpréter comme une année compris entre :"

j'ai fait des recherches et je suis tombé sur GetLocaleInfoA de kernel32

- 1°) est ce la bonne api à utliser ?
- 2°) si oui alors comment le faire car j'ai beau tout essayer et je n'y
parviens pas
- 3°) comment récupérer les valeurs des constantes pour les api ?



Doc de l'API:

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

· Locale
[in] Specifies the locale to retrieve information for. This parameter can be
a locale identifier created by the MAKELCID macro, or one of the following
predefined values:
Value Description
LOCALE_SYSTEM_DEFAULT Default system locale.
LOCALE_USER_DEFAULT Default user locale.
LOCALE_NEUTRAL Default language-neutral locale.

· LCType
[in] Specifies one of the LCTYPE constants to indicate the type of
information to be retrieved.
All LCTYPE values are mutually exclusive, with the exception of
LOCALE_NOUSEROVERRIDE. An application may use the binary-OR operator to
combine LOCALE_NOUSEROVERRIDE with any other LCTYPE value. If passed such an
LCType value, the function bypasses user overrides, and returns the system
default value for the requested LCID.

· lpLCData
[out] Pointer to a buffer to receive the requested data.

· cchData
[in] Specifies the size, in characters, of the lpLCData buffer. If cchData is
zero, the function returns the number of characters required to hold the
information, and the buffer pointed to by lpLCData is not used.

Exemple VB:
Const LOCALE_USER_DEFAULT = &H400
Const LOCALE_SENGCOUNTRY = &H1002 ' English name of country
Const LOCALE_SENGLANGUAGE = &H1001 ' English name of language
Const LOCALE_SNATIVELANGNAME = &H4 ' native name of language
Const LOCALE_SNATIVECTRYNAME = &H8 ' native name of country
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 Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail:
MsgBox "You live in " & GetInfo(LOCALE_SENGCOUNTRY) & " (" &
GetInfo(LOCALE_SNATIVECTRYNAME) & ")," & vbCrLf & "and you speak " &
GetInfo(LOCALE_SENGLANGUAGE) & " (" & GetInfo(LOCALE_SNATIVELANGNAME) & ").",
vbInformation
End Sub
Public Function GetInfo(ByVal lInfo As Long) As String
Dim Buffer As String, Ret As String
Buffer = String$(256, 0)
Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
If Ret > 0 Then
GetInfo = Left$(Buffer, Ret - 1)
Else
GetInfo = ""
End If
End Function

Cela semble bien être la bonne API , mais il manque à trouver la bonne valeur
de LCTYPE ?



merci mais l'exemple est faux ilmanque des param

--
Cordialement JeAn-PhI
Avatar
Thumain Th.
Le Mon, 03 Nov 2008 18:46:11 +0100, JeAn-PhI a écrit:

Après mûre réflexion, Thumain Th. a écrit :
Le Mon, 03 Nov 2008 16:33:00 +0100, JeAn-PhI a écrit:

bonjour

je cherche à récupérer les infos suivantes :

Panneau de config|Options régionales et linguistiques|bouton
Personnaliser|onglet Date| les valeurs des champs : "Quand une année
sur 2 chiffres est entrée, l'interpréter comme une année compris entre
:"






[...]
Buffer = String$(256, 0)
Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer,
Len(Buffer))
If Ret > 0 Then
GetInfo = Left$(Buffer, Ret - 1)
Else
GetInfo = ""
End If
End Function

Cela semble bien être la bonne API , mais il manque à trouver la bonne
valeur de LCTYPE ?



merci mais l'exemple est faux ilmanque des param



Je ne pense pas , quatre arguments :
http://msdn.microsoft.com/en-us/library/ms776270(VS.85).aspx



--
TT
Avatar
JeAn-PhI
Le 03/11/2008, Thumain Th. a supposé :
Le Mon, 03 Nov 2008 18:46:11 +0100, JeAn-PhI a écrit:

Après mûre réflexion, Thumain Th. a écrit :
Le Mon, 03 Nov 2008 16:33:00 +0100, JeAn-PhI a écrit:

bonjour

je cherche à récupérer les infos suivantes :

Panneau de config|Options régionales et linguistiques|bouton
Personnaliser|onglet Date| les valeurs des champs : "Quand une année sur
2 chiffres est entrée, l'interpréter comme une année compris entre
:"






[...]
Buffer = String$(256, 0)
Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
If Ret > 0 Then
GetInfo = Left$(Buffer, Ret - 1)
Else
GetInfo = ""
End If
End Function

Cela semble bien être la bonne API , mais il manque à trouver la bonne
valeur de LCTYPE ?



merci mais l'exemple est faux ilmanque des param



Je ne pense pas , quatre arguments :
http://msdn.microsoft.com/en-us/library/ms776270(VS.85).aspx



désolé j'ai confondu avec GetCalendarInfo

--
Cordialement JeAn-PhI
Avatar
JeAn-PhI
JeAn-PhI avait énoncé :
bonjour

je cherche à récupérer les infos suivantes :

Panneau de config|Options régionales et linguistiques|bouton
Personnaliser|onglet Date| les valeurs des champs : "Quand une année sur 2
chiffres est entrée, l'interpréter comme une année compris entre
:"

j'ai fait des recherches et je suis tombé sur GetLocaleInfoA de kernel32

- 1°) est ce la bonne api à utliser ?
- 2°) si oui alors comment le faire car j'ai beau tout essayer et je n'y
parviens pas
- 3°) comment récupérer les valeurs des constantes pour les api ?



en fait il me semble que la bonne API est GetCalendarInfo et la
constante CAL_IYEAROFFSETRANGE mais je n'y arrive pas

un peu d'aide merci

--
Cordialement JeAn-PhI