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

udat_open

関数
スタイルやパターンを指定し日付フォーマッタを開く。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

void** udat_open(
    UDateFormatStyle timeStyle,
    UDateFormatStyle dateStyle,
    LPCSTR locale,
    const WORD* tzID,
    INT tzIDLength,
    const WORD* pattern,
    INT patternLength,
    UErrorCode* status
);

パラメーター

名前方向
timeStyleUDateFormatStylein
dateStyleUDateFormatStylein
localeLPCSTRin
tzIDWORD*in
tzIDLengthINTin
patternWORD*in
patternLengthINTin
statusUErrorCode*inout

戻り値の型: void**

各言語での呼び出し定義

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

void** udat_open(
    UDateFormatStyle timeStyle,
    UDateFormatStyle dateStyle,
    LPCSTR locale,
    const WORD* tzID,
    INT tzIDLength,
    const WORD* pattern,
    INT patternLength,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr udat_open(
    int timeStyle,   // UDateFormatStyle
    int dateStyle,   // UDateFormatStyle
    [MarshalAs(UnmanagedType.LPStr)] string locale,   // LPCSTR
    ref ushort tzID,   // WORD*
    int tzIDLength,   // INT
    ref ushort pattern,   // WORD*
    int patternLength,   // INT
    ref int status   // UErrorCode* in/out
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function udat_open(
    timeStyle As Integer,   ' UDateFormatStyle
    dateStyle As Integer,   ' UDateFormatStyle
    <MarshalAs(UnmanagedType.LPStr)> locale As String,   ' LPCSTR
    ByRef tzID As UShort,   ' WORD*
    tzIDLength As Integer,   ' INT
    ByRef pattern As UShort,   ' WORD*
    patternLength As Integer,   ' INT
    ByRef status As Integer   ' UErrorCode* in/out
) As IntPtr
End Function
' timeStyle : UDateFormatStyle
' dateStyle : UDateFormatStyle
' locale : LPCSTR
' tzID : WORD*
' tzIDLength : INT
' pattern : WORD*
' patternLength : INT
' status : UErrorCode* in/out
Declare PtrSafe Function udat_open Lib "icuin" ( _
    ByVal timeStyle As Long, _
    ByVal dateStyle As Long, _
    ByVal locale As String, _
    ByRef tzID As Integer, _
    ByVal tzIDLength As Long, _
    ByRef pattern As Integer, _
    ByVal patternLength As Long, _
    ByRef status As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

udat_open = ctypes.cdll.icuin.udat_open
udat_open.restype = ctypes.c_void_p
udat_open.argtypes = [
    ctypes.c_int,  # timeStyle : UDateFormatStyle
    ctypes.c_int,  # dateStyle : UDateFormatStyle
    wintypes.LPCSTR,  # locale : LPCSTR
    ctypes.POINTER(ctypes.c_ushort),  # tzID : WORD*
    ctypes.c_int,  # tzIDLength : INT
    ctypes.POINTER(ctypes.c_ushort),  # pattern : WORD*
    ctypes.c_int,  # patternLength : INT
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procudat_open = icuin.NewProc("udat_open")
)

// timeStyle (UDateFormatStyle), dateStyle (UDateFormatStyle), locale (LPCSTR), tzID (WORD*), tzIDLength (INT), pattern (WORD*), patternLength (INT), status (UErrorCode* in/out)
r1, _, err := procudat_open.Call(
	uintptr(timeStyle),
	uintptr(dateStyle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
	uintptr(tzID),
	uintptr(tzIDLength),
	uintptr(pattern),
	uintptr(patternLength),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void**
function udat_open(
  timeStyle: Integer;   // UDateFormatStyle
  dateStyle: Integer;   // UDateFormatStyle
  locale: PAnsiChar;   // LPCSTR
  tzID: Pointer;   // WORD*
  tzIDLength: Integer;   // INT
  pattern: Pointer;   // WORD*
  patternLength: Integer;   // INT
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuin.dll' name 'udat_open';
result := DllCall("icuin\udat_open"
    , "Int", timeStyle   ; UDateFormatStyle
    , "Int", dateStyle   ; UDateFormatStyle
    , "AStr", locale   ; LPCSTR
    , "Ptr", tzID   ; WORD*
    , "Int", tzIDLength   ; INT
    , "Ptr", pattern   ; WORD*
    , "Int", patternLength   ; INT
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: void**
●udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status) = DLL("icuin.dll", "void* udat_open(int, int, char*, void*, int, void*, int, void*)")
# 呼び出し: udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
# timeStyle : UDateFormatStyle -> "int"
# dateStyle : UDateFormatStyle -> "int"
# locale : LPCSTR -> "char*"
# tzID : WORD* -> "void*"
# tzIDLength : INT -> "int"
# pattern : WORD* -> "void*"
# patternLength : INT -> "int"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。