|
发表于 2013-1-30 08:40:42
|
显示全部楼层
本帖最后由 netegg 于 2013-1-30 08:45 编辑
[au3]Global Const $tagNUMBERFMT = 'uint NumDigits;uint LeadingZero;uint Grouping;ptr DecimalSep;ptr ThousandSep;uint NegativeOrder;'
Global Const $tagCURRENCYFMT = $tagNUMBERFMT & 'uint PositiveOrder;ptr CurrencySymbol;'
Local $Number = -123456.569
Local $Number1 = 123456.569
MsgBox(0,0,_WinAPI_GetCurrencyFormat(0, $Number)&@crlf&_WinAPI_GetCurrencyFormat(0, $Number1))
Func _WinAPI_CreateCurrencyFormatInfo($iNumDigits, $iLeadingZero, $iGrouping, $sDecimalSep, $sThousandSep, $iNegativeOrder, $iPositiveOrder, $sCurrencySymbol)
Local $tFMT = DllStructCreate($tagCURRENCYFMT & 'wchar[' & (StringLen($sDecimalSep) + 1) & '];wchar[' & (StringLen($sThousandSep) + 1) & '];wchar[' & (StringLen($sCurrencySymbol) + 1) & ']')
DllStructSetData($tFMT, 1, $iNumDigits)
DllStructSetData($tFMT, 2, $iLeadingZero)
DllStructSetData($tFMT, 3, $iGrouping)
DllStructSetData($tFMT, 4, DllStructGetPtr($tFMT, 9))
DllStructSetData($tFMT, 5, DllStructGetPtr($tFMT, 10))
DllStructSetData($tFMT, 6, $iNegativeOrder)
DllStructSetData($tFMT, 7, $iPositiveOrder)
DllStructSetData($tFMT, 8, DllStructGetPtr($tFMT, 11))
DllStructSetData($tFMT, 9, $sDecimalSep)
DllStructSetData($tFMT, 10, $sThousandSep)
DllStructSetData($tFMT, 11, $sCurrencySymbol)
Return $tFMT
EndFunc ;==>_WinAPI_CreateCurrencyFormatInfo
Func _WinAPI_GetCurrencyFormat($LCID, $sNumber, $tCURRENCYFMT = 0)
If Not $LCID Then
$LCID = 0x0400
EndIf
Local $Ret = DllCall('kernel32.dll', 'int', 'GetCurrencyFormatW', 'ulong', $LCID, 'dword', 0, 'wstr', $sNumber, 'ptr', DllStructGetPtr($tCURRENCYFMT), 'wstr', '', 'int', 2048)
If (@error) Or (Not $Ret[0]) Then
Return SetError(1, 0, '')
EndIf
Return $Ret[5]
EndFunc ;==>_WinAPI_GetCurrencyFormat[/au3] |
|