Тема: AHK: Перенести функцию с AHK v2 в v1
Нашел такую функцию для AHK v2:
GetCurrencyFormat(Value, Locale := 0x0400)
{
if (Size := DllCall("GetCurrencyFormatW", "UInt", Locale, "UInt", 0, "Str", Value, "Ptr", 0, "Ptr", 0, "Int", 0))
{
Size := VarSetStrCapacity(&CurrencyStr, Size)
if (Size := DllCall("GetCurrencyFormatW", "UInt", Locale, "UInt", 0, "Str", Value, "Ptr", 0, "Str", CurrencyStr, "Int", Size))
{
return CurrencyStr
}
}
return ""
}
; =================================
MsgBox GetCurrencyFormat(1149.99) ; 1.149,99 € ( LANG_USER_DEFAULT | SUBLANG_DEFAULT ) (GERMAN HERE)
MsgBox GetCurrencyFormat(1149.99, 0x0409) ; $1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_US )
MsgBox GetCurrencyFormat(1149.99, 0x0809) ; £1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_UK )
MsgBox GetCurrencyFormat(1149.99, 0x0407) ; 1.149,99 € ( LANG_GERMAN | SUBLANG_GERMAN )
Как ее перенести в v1? Мои познания в DllCall нулевые.
Значение первого Size пустое.
GetCurrencyFormat(Value, Locale := 0x0400)
{
if (Size := DllCall("GetCurrencyFormatW", "UInt", Locale, "UInt", 0, "Str", Value, "Ptr", 0, "Ptr", 0, "Int", 0))
{
Size := VarSetCapacity(&CurrencyStr, Size)
if (Size := DllCall("GetCurrencyFormatW", "UInt", Locale, "UInt", 0, "Str", Value, "Ptr", 0, "Str", CurrencyStr, "Int", Size))
{
return CurrencyStr
}
}
return ""
}
; ==================
MsgBox % GetCurrencyFormat(1149.99) ; 1.149,99 € ( LANG_USER_DEFAULT | SUBLANG_DEFAULT ) (GERMAN HERE)
MsgBox % GetCurrencyFormat(1149.99, 0x0409) ; $1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_US )
MsgBox % GetCurrencyFormat(1149.99, 0x0809) ; £1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_UK )
MsgBox % GetCurrencyFormat(1149.99, 0x0407) ; 1.149,99 € ( LANG_GERMAN | SUBLANG_GERMAN )