Win32 API 日本語リファレンス
ホームGlobalization › ucurr_forLocaleAndDate

ucurr_forLocaleAndDate

関数
指定ロケールと日付で有効な通貨コードを取得する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

INT ucurr_forLocaleAndDate(
    LPCSTR locale,
    DOUBLE date,
    INT index,
    WORD* buff,
    INT buffCapacity,
    UErrorCode* ec
);

パラメーター

名前方向
localeLPCSTRin
dateDOUBLEin
indexINTin
buffWORD*inout
buffCapacityINTin
ecUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

// icuuc.dll
#include <windows.h>

INT ucurr_forLocaleAndDate(
    LPCSTR locale,
    DOUBLE date,
    INT index,
    WORD* buff,
    INT buffCapacity,
    UErrorCode* ec
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucurr_forLocaleAndDate(
    [MarshalAs(UnmanagedType.LPStr)] string locale,   // LPCSTR
    double date,   // DOUBLE
    int index,   // INT
    ref ushort buff,   // WORD* in/out
    int buffCapacity,   // INT
    ref int ec   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucurr_forLocaleAndDate(
    <MarshalAs(UnmanagedType.LPStr)> locale As String,   ' LPCSTR
    [date] As Double,   ' DOUBLE
    index As Integer,   ' INT
    ByRef buff As UShort,   ' WORD* in/out
    buffCapacity As Integer,   ' INT
    ByRef ec As Integer   ' UErrorCode* in/out
) As Integer
End Function
' locale : LPCSTR
' date : DOUBLE
' index : INT
' buff : WORD* in/out
' buffCapacity : INT
' ec : UErrorCode* in/out
Declare PtrSafe Function ucurr_forLocaleAndDate Lib "icuuc" ( _
    ByVal locale As String, _
    ByVal date As Double, _
    ByVal index As Long, _
    ByRef buff As Integer, _
    ByVal buffCapacity As Long, _
    ByRef ec As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ucurr_forLocaleAndDate = ctypes.cdll.icuuc.ucurr_forLocaleAndDate
ucurr_forLocaleAndDate.restype = ctypes.c_int
ucurr_forLocaleAndDate.argtypes = [
    wintypes.LPCSTR,  # locale : LPCSTR
    ctypes.c_double,  # date : DOUBLE
    ctypes.c_int,  # index : INT
    ctypes.POINTER(ctypes.c_ushort),  # buff : WORD* in/out
    ctypes.c_int,  # buffCapacity : INT
    ctypes.c_void_p,  # ec : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
ucurr_forLocaleAndDate = Fiddle::Function.new(
  lib['ucurr_forLocaleAndDate'],
  [
    Fiddle::TYPE_VOIDP,  # locale : LPCSTR
    Fiddle::TYPE_DOUBLE,  # date : DOUBLE
    Fiddle::TYPE_INT,  # index : INT
    Fiddle::TYPE_VOIDP,  # buff : WORD* in/out
    Fiddle::TYPE_INT,  # buffCapacity : INT
    Fiddle::TYPE_VOIDP,  # ec : UErrorCode* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn ucurr_forLocaleAndDate(
        locale: *const u8,  // LPCSTR
        date: f64,  // DOUBLE
        index: i32,  // INT
        buff: *mut u16,  // WORD* in/out
        buffCapacity: i32,  // INT
        ec: *mut i32  // UErrorCode* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int ucurr_forLocaleAndDate([MarshalAs(UnmanagedType.LPStr)] string locale, double date, int index, ref ushort buff, int buffCapacity, ref int ec);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucurr_forLocaleAndDate' -Namespace Win32 -PassThru
# $api::ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)
#uselib "icuuc.dll"
#func global ucurr_forLocaleAndDate "ucurr_forLocaleAndDate" sptr, double, sptr, sptr, sptr, sptr
; ucurr_forLocaleAndDate locale, date, index, varptr(buff), buffCapacity, ec   ; 戻り値は stat
; locale : LPCSTR -> "sptr"
; date : DOUBLE -> "double"
; index : INT -> "sptr"
; buff : WORD* in/out -> "sptr"
; buffCapacity : INT -> "sptr"
; ec : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global ucurr_forLocaleAndDate "ucurr_forLocaleAndDate" str, double, int, var, int, int
; res = ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)
; locale : LPCSTR -> "str"
; date : DOUBLE -> "double"
; index : INT -> "int"
; buff : WORD* in/out -> "var"
; buffCapacity : INT -> "int"
; ec : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT ucurr_forLocaleAndDate(LPCSTR locale, DOUBLE date, INT index, WORD* buff, INT buffCapacity, UErrorCode* ec)
#uselib "icuuc.dll"
#cfunc global ucurr_forLocaleAndDate "ucurr_forLocaleAndDate" str, double, int, var, int, int
; res = ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)
; locale : LPCSTR -> "str"
; date : DOUBLE -> "double"
; index : INT -> "int"
; buff : WORD* in/out -> "var"
; buffCapacity : INT -> "int"
; ec : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"math"
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procucurr_forLocaleAndDate = icuuc.NewProc("ucurr_forLocaleAndDate")
)

// locale (LPCSTR), date (DOUBLE), index (INT), buff (WORD* in/out), buffCapacity (INT), ec (UErrorCode* in/out)
r1, _, err := procucurr_forLocaleAndDate.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
	uintptr(math.Float64bits(date)),
	uintptr(index),
	uintptr(buff),
	uintptr(buffCapacity),
	uintptr(ec),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。
function ucurr_forLocaleAndDate(
  locale: PAnsiChar;   // LPCSTR
  date: Double;   // DOUBLE
  index: Integer;   // INT
  buff: Pointer;   // WORD* in/out
  buffCapacity: Integer;   // INT
  ec: Pointer   // UErrorCode* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'ucurr_forLocaleAndDate';
result := DllCall("icuuc\ucurr_forLocaleAndDate"
    , "AStr", locale   ; LPCSTR
    , "Double", date   ; DOUBLE
    , "Int", index   ; INT
    , "Ptr", buff   ; WORD* in/out
    , "Int", buffCapacity   ; INT
    , "Ptr", ec   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: INT
●ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec) = DLL("icuuc.dll", "int ucurr_forLocaleAndDate(char*, double, int, void*, int, void*)")
# 呼び出し: ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)
# locale : LPCSTR -> "char*"
# date : DOUBLE -> "double"
# index : INT -> "int"
# buff : WORD* in/out -> "void*"
# buffCapacity : INT -> "int"
# ec : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。