Faceți căutări pe acest blog
duminică, 14 iunie 2015
Using GetLocaleInfo and GetLocaleInfoEx for currencies (1)
GetLocaleInfo and GetLocaleInfoEx can be used to get the local settings for currencies (the ones from Control Panel -> Regional Settings)
Both GetLocaleInfo and GetLocaleInfoEx gives plenty of informations. They can be invoked similarly, and gives similar results.
The main difference between the the functions signature is the first parameter. GetLocaleInfo have a LONG parameter, while GetLocaleInfoEx a character parameter.
GetLocaleInfo can be used in Windows XP, Vista and above. GetLocaleInfo tends to become deprecated.
GetLocaleInfoEx can be used in Windows Vista and above, but cannot be used in Windows XP.
GetLocaleInfo provide ASCII results, while GetLocaleInfoEx supports Unicode.
This means many currencies (like English India) can be obtained only with GetLocaleInfoEx.
To get the values for the default settings, the first parameter of GetLocaleInfoEx must be Null.
For other values, use the format <language> - <REGION>, but converted to Unicode
For example
StrConv ("en-AU", 5) + CHR (0)
or
StrConv ("en-US", 5) + CHR (0)
****************
* Begin code
****************
Declare INTEGER GetLocaleInfo in Win32API LONG Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
Declare INTEGER GetLocaleInfoEx in Win32API String Locale, LONG LCType, STRING @LpLCData, INTEGER cchData
LOCAL LpLCData,cchData,nretval
LpLCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
? "currency symbol - user default"
LPCWSTR = Null
nretval = GetLocaleInfoEx(LPCWSTR, 0x14, @LpLCData, cchData)
?nretval,LpLCData,TRANSFORM(ASC(SUBSTR(LpLCData,2)),"@0"),TRANSFORM(ASC(LpLCData),"@0") && Euro (Unicode 0x20 0x0AC)
? "currency symbol - english - Great Britain"
LPCWSTR = STRCONV("en-GB",5)+CHR(0)
nretval = GetLocaleInfoEx(LPCWSTR, 0x14, @LpLCData, cchData)
?nretval,LpLCData,TRANSFORM(ASC(SUBSTR(LpLCData,2)),"@0"),TRANSFORM(ASC(LpLCData),"@0") && pounds (Unicode 0x000 0x0A3 ou ASCII 0xA3)
? "currency symbol"
nretval = GetLocaleInfo(1024, 0x14, @LpLCData, cchData)
?nretval,LEFT(LpLCData,nretval-1)
nretval = GetLocaleInfoEx(Null, 0x14, @LpLCData, cchData)
?nretval
FOR lni = 1 TO nretval-1
?? TRANSFORM(ASC(SUBSTR(LpLCData,2*lni)),"@0"),TRANSFORM(ASC(SUBSTR(LpLCData,2*lni-1)),"@0")
NEXT
? "currency position"
nretval = GetLocaleInfoEx(Null, 0x1B, @LpLCData, cchData)
?nretval,LpLCData
? "decimal separator"
nretval = GetLocaleInfoEx(Null, 0x16, @LpLCData, cchData)
?nretval,LpLCData
? "thousand separator"
nretval = GetLocaleInfoEx(Null, 0x17, @LpLCData, cchData)
?nretval,LpLCData
? "number of decimals"
nretval = GetLocaleInfoEx(Null, 0x19, @LpLCData, cchData)
?nretval,LpLCData
****************
* End code
****************
Biblio
http://www.foxite.com/archives/getlocaleinfoex-fountain-of-knowledge-0000424218.htm
ftp://ftp.microsoft.com/misc1/DEVELOPR/FOX/KB/Q177/1/46.TXT
https://msdn.microsoft.com/en-us/library/windows/desktop/dd318103%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/dd318101%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/dd464799%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/dd373755%28v=vs.85%29.aspx
http://www.pinvoke.net/default.aspx/kernel32/GetLocaleInfoEx.html
Related posts
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_79.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex_14.html
http://praisachion.blogspot.com/2015/06/using-getlocaleinfo-and-getlocaleinfoex.html
Abonați-vă la:
Postare comentarii (Atom)
Niciun comentariu:
Trimiteți un comentariu