Win32 API 日本語リファレンス
ホームSystem.Time › GetDynamicTimeZoneInformation

GetDynamicTimeZoneInformation

関数
システムの動的タイムゾーン情報を取得する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

DWORD GetDynamicTimeZoneInformation(
    DYNAMIC_TIME_ZONE_INFORMATION* pTimeZoneInformation
);

パラメーター

名前方向
pTimeZoneInformationDYNAMIC_TIME_ZONE_INFORMATION*out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetDynamicTimeZoneInformation(
    DYNAMIC_TIME_ZONE_INFORMATION* pTimeZoneInformation
);
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern uint GetDynamicTimeZoneInformation(
    IntPtr pTimeZoneInformation   // DYNAMIC_TIME_ZONE_INFORMATION* out
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetDynamicTimeZoneInformation(
    pTimeZoneInformation As IntPtr   ' DYNAMIC_TIME_ZONE_INFORMATION* out
) As UInteger
End Function
' pTimeZoneInformation : DYNAMIC_TIME_ZONE_INFORMATION* out
Declare PtrSafe Function GetDynamicTimeZoneInformation Lib "kernel32" ( _
    ByVal pTimeZoneInformation As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetDynamicTimeZoneInformation = ctypes.windll.kernel32.GetDynamicTimeZoneInformation
GetDynamicTimeZoneInformation.restype = wintypes.DWORD
GetDynamicTimeZoneInformation.argtypes = [
    ctypes.c_void_p,  # pTimeZoneInformation : DYNAMIC_TIME_ZONE_INFORMATION* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetDynamicTimeZoneInformation = Fiddle::Function.new(
  lib['GetDynamicTimeZoneInformation'],
  [
    Fiddle::TYPE_VOIDP,  # pTimeZoneInformation : DYNAMIC_TIME_ZONE_INFORMATION* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn GetDynamicTimeZoneInformation(
        pTimeZoneInformation: *mut DYNAMIC_TIME_ZONE_INFORMATION  // DYNAMIC_TIME_ZONE_INFORMATION* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern uint GetDynamicTimeZoneInformation(IntPtr pTimeZoneInformation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetDynamicTimeZoneInformation' -Namespace Win32 -PassThru
# $api::GetDynamicTimeZoneInformation(pTimeZoneInformation)
#uselib "KERNEL32.dll"
#func global GetDynamicTimeZoneInformation "GetDynamicTimeZoneInformation" sptr
; GetDynamicTimeZoneInformation varptr(pTimeZoneInformation)   ; 戻り値は stat
; pTimeZoneInformation : DYNAMIC_TIME_ZONE_INFORMATION* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global GetDynamicTimeZoneInformation "GetDynamicTimeZoneInformation" var
; res = GetDynamicTimeZoneInformation(pTimeZoneInformation)
; pTimeZoneInformation : DYNAMIC_TIME_ZONE_INFORMATION* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD GetDynamicTimeZoneInformation(DYNAMIC_TIME_ZONE_INFORMATION* pTimeZoneInformation)
#uselib "KERNEL32.dll"
#cfunc global GetDynamicTimeZoneInformation "GetDynamicTimeZoneInformation" var
; res = GetDynamicTimeZoneInformation(pTimeZoneInformation)
; pTimeZoneInformation : DYNAMIC_TIME_ZONE_INFORMATION* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetDynamicTimeZoneInformation = kernel32.NewProc("GetDynamicTimeZoneInformation")
)

// pTimeZoneInformation (DYNAMIC_TIME_ZONE_INFORMATION* out)
r1, _, err := procGetDynamicTimeZoneInformation.Call(
	uintptr(pTimeZoneInformation),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetDynamicTimeZoneInformation(
  pTimeZoneInformation: Pointer   // DYNAMIC_TIME_ZONE_INFORMATION* out
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'GetDynamicTimeZoneInformation';
result := DllCall("KERNEL32\GetDynamicTimeZoneInformation"
    , "Ptr", pTimeZoneInformation   ; DYNAMIC_TIME_ZONE_INFORMATION* out
    , "UInt")   ; return: DWORD
●GetDynamicTimeZoneInformation(pTimeZoneInformation) = DLL("KERNEL32.dll", "dword GetDynamicTimeZoneInformation(void*)")
# 呼び出し: GetDynamicTimeZoneInformation(pTimeZoneInformation)
# pTimeZoneInformation : DYNAMIC_TIME_ZONE_INFORMATION* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。