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

ucal_getTimeZoneIDForWindowsID

関数
WindowsのタイムゾーンIDをICUのIDへ変換する。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

INT ucal_getTimeZoneIDForWindowsID(
    const WORD* winid,
    INT len,
    LPCSTR region,
    WORD* id,
    INT idCapacity,
    UErrorCode* status
);

パラメーター

名前方向
winidWORD*in
lenINTin
regionLPCSTRin
idWORD*inout
idCapacityINTin
statusUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

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

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

ucal_getTimeZoneIDForWindowsID = ctypes.cdll.icuin.ucal_getTimeZoneIDForWindowsID
ucal_getTimeZoneIDForWindowsID.restype = ctypes.c_int
ucal_getTimeZoneIDForWindowsID.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # winid : WORD*
    ctypes.c_int,  # len : INT
    wintypes.LPCSTR,  # region : LPCSTR
    ctypes.POINTER(ctypes.c_ushort),  # id : WORD* in/out
    ctypes.c_int,  # idCapacity : INT
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procucal_getTimeZoneIDForWindowsID = icuin.NewProc("ucal_getTimeZoneIDForWindowsID")
)

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