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

ucal_getHostTimeZone

関数
ホストOSのタイムゾーンIDを取得する。
DLLicu.dll呼出規約cdecl

シグネチャ

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

INT ucal_getHostTimeZone(
    WORD* result,
    INT resultCapacity,
    UErrorCode* ec
);

パラメーター

名前方向
resultWORD*inout
resultCapacityINTin
ecUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT ucal_getHostTimeZone(
    WORD* result,
    INT resultCapacity,
    UErrorCode* ec
);
[DllImport("icu.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucal_getHostTimeZone(
    ref ushort result,   // WORD* in/out
    int resultCapacity,   // INT
    ref int ec   // UErrorCode* in/out
);
<DllImport("icu.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucal_getHostTimeZone(
    ByRef result As UShort,   ' WORD* in/out
    resultCapacity As Integer,   ' INT
    ByRef ec As Integer   ' UErrorCode* in/out
) As Integer
End Function
' result : WORD* in/out
' resultCapacity : INT
' ec : UErrorCode* in/out
Declare PtrSafe Function ucal_getHostTimeZone Lib "icu" ( _
    ByRef result As Integer, _
    ByVal resultCapacity 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

ucal_getHostTimeZone = ctypes.cdll.icu.ucal_getHostTimeZone
ucal_getHostTimeZone.restype = ctypes.c_int
ucal_getHostTimeZone.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # result : WORD* in/out
    ctypes.c_int,  # resultCapacity : INT
    ctypes.c_void_p,  # ec : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icu = windows.NewLazySystemDLL("icu.dll")
	procucal_getHostTimeZone = icu.NewProc("ucal_getHostTimeZone")
)

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