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

GetSystemLeapSecondInformation

関数
うるう秒の有効状態と関連フラグを取得する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

BOOL GetSystemLeapSecondInformation(
    BOOL* Enabled,
    DWORD* Flags
);

パラメーター

名前方向説明
EnabledBOOL*outうるう秒処理が有効かどうかを受け取る BOOL ポインタ。
FlagsDWORD*outうるう秒に関する追加フラグを受け取る DWORD ポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetSystemLeapSecondInformation(
    BOOL* Enabled,
    DWORD* Flags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool GetSystemLeapSecondInformation(
    out bool Enabled,   // BOOL* out
    out uint Flags   // DWORD* out
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function GetSystemLeapSecondInformation(
    <Out> ByRef Enabled As Boolean,   ' BOOL* out
    <Out> ByRef Flags As UInteger   ' DWORD* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' Enabled : BOOL* out
' Flags : DWORD* out
Declare PtrSafe Function GetSystemLeapSecondInformation Lib "kernel32" ( _
    ByRef Enabled As Long, _
    ByRef Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetSystemLeapSecondInformation = ctypes.windll.kernel32.GetSystemLeapSecondInformation
GetSystemLeapSecondInformation.restype = wintypes.BOOL
GetSystemLeapSecondInformation.argtypes = [
    ctypes.c_void_p,  # Enabled : BOOL* out
    ctypes.POINTER(wintypes.DWORD),  # Flags : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetSystemLeapSecondInformation = kernel32.NewProc("GetSystemLeapSecondInformation")
)

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

extern "kernel32" fn GetSystemLeapSecondInformation(
    Enabled: [*c]i32, // BOOL* out
    Flags: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;
proc GetSystemLeapSecondInformation(
    Enabled: ptr int32,  # BOOL* out
    Flags: ptr uint32  # DWORD* out
): int32 {.importc: "GetSystemLeapSecondInformation", stdcall, dynlib: "KERNEL32.dll".}
pragma(lib, "kernel32");
extern(Windows)
int GetSystemLeapSecondInformation(
    int* Enabled,   // BOOL* out
    uint* Flags   // DWORD* out
);
ccall((:GetSystemLeapSecondInformation, "KERNEL32.dll"), stdcall, Int32,
      (Ptr{Int32}, Ptr{UInt32}),
      Enabled, Flags)
# Enabled : BOOL* out -> Ptr{Int32}
# Flags : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetSystemLeapSecondInformation(
    int32_t* Enabled,
    uint32_t* Flags);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.GetSystemLeapSecondInformation(Enabled, Flags)
-- Enabled : BOOL* out
-- Flags : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const GetSystemLeapSecondInformation = lib.func('__stdcall', 'GetSystemLeapSecondInformation', 'int32_t', ['int32_t *', 'uint32_t *']);
// GetSystemLeapSecondInformation(Enabled, Flags)
// Enabled : BOOL* out -> 'int32_t *'
// Flags : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  GetSystemLeapSecondInformation: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetSystemLeapSecondInformation(Enabled, Flags)
// Enabled : BOOL* out -> "pointer"
// Flags : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetSystemLeapSecondInformation(
    int32_t* Enabled,
    uint32_t* Flags);
C, "KERNEL32.dll");
// $ffi->GetSystemLeapSecondInformation(Enabled, Flags);
// Enabled : BOOL* out
// Flags : DWORD* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Kernel32 extends StdCallLibrary {
    Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
    boolean GetSystemLeapSecondInformation(
        IntByReference Enabled,   // BOOL* out
        IntByReference Flags   // DWORD* out
    );
}
@[Link("kernel32")]
lib LibKERNEL32
  fun GetSystemLeapSecondInformation = GetSystemLeapSecondInformation(
    Enabled : Int32*,   # BOOL* out
    Flags : UInt32*   # DWORD* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetSystemLeapSecondInformationNative = Int32 Function(Pointer<Int32>, Pointer<Uint32>);
typedef GetSystemLeapSecondInformationDart = int Function(Pointer<Int32>, Pointer<Uint32>);
final GetSystemLeapSecondInformation = DynamicLibrary.open('KERNEL32.dll')
    .lookupFunction<GetSystemLeapSecondInformationNative, GetSystemLeapSecondInformationDart>('GetSystemLeapSecondInformation');
// Enabled : BOOL* out -> Pointer<Int32>
// Flags : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetSystemLeapSecondInformation(
  Enabled: Pointer;   // BOOL* out
  Flags: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'GetSystemLeapSecondInformation';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetSystemLeapSecondInformation"
  c_GetSystemLeapSecondInformation :: Ptr CInt -> Ptr Word32 -> IO CInt
-- Enabled : BOOL* out -> Ptr CInt
-- Flags : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getsystemleapsecondinformation =
  foreign "GetSystemLeapSecondInformation"
    ((ptr int32_t) @-> (ptr uint32_t) @-> returning int32_t)
(* Enabled : BOOL* out -> (ptr int32_t) *)
(* Flags : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)

(cffi:defcfun ("GetSystemLeapSecondInformation" get-system-leap-second-information :convention :stdcall) :int32
  (enabled :pointer)   ; BOOL* out
  (flags :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetSystemLeapSecondInformation = Win32::API::More->new('KERNEL32',
    'BOOL GetSystemLeapSecondInformation(LPVOID Enabled, LPVOID Flags)');
# my $ret = $GetSystemLeapSecondInformation->Call($Enabled, $Flags);
# Enabled : BOOL* out -> LPVOID
# Flags : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。