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

IsCalendarLeapYear

関数
指定暦の年がうるう年か判定する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

BOOL IsCalendarLeapYear(
    DWORD calId,
    DWORD year,
    DWORD era
);

パラメーター

名前方向
calIdDWORDin
yearDWORDin
eraDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

IsCalendarLeapYear = ctypes.windll.kernel32.IsCalendarLeapYear
IsCalendarLeapYear.restype = wintypes.BOOL
IsCalendarLeapYear.argtypes = [
    wintypes.DWORD,  # calId : DWORD
    wintypes.DWORD,  # year : DWORD
    wintypes.DWORD,  # era : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
IsCalendarLeapYear = Fiddle::Function.new(
  lib['IsCalendarLeapYear'],
  [
    -Fiddle::TYPE_INT,  # calId : DWORD
    -Fiddle::TYPE_INT,  # year : DWORD
    -Fiddle::TYPE_INT,  # era : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn IsCalendarLeapYear(
        calId: u32,  // DWORD
        year: u32,  // DWORD
        era: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool IsCalendarLeapYear(uint calId, uint year, uint era);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_IsCalendarLeapYear' -Namespace Win32 -PassThru
# $api::IsCalendarLeapYear(calId, year, era)
#uselib "KERNEL32.dll"
#func global IsCalendarLeapYear "IsCalendarLeapYear" sptr, sptr, sptr
; IsCalendarLeapYear calId, year, era   ; 戻り値は stat
; calId : DWORD -> "sptr"
; year : DWORD -> "sptr"
; era : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global IsCalendarLeapYear "IsCalendarLeapYear" int, int, int
; res = IsCalendarLeapYear(calId, year, era)
; calId : DWORD -> "int"
; year : DWORD -> "int"
; era : DWORD -> "int"
; BOOL IsCalendarLeapYear(DWORD calId, DWORD year, DWORD era)
#uselib "KERNEL32.dll"
#cfunc global IsCalendarLeapYear "IsCalendarLeapYear" int, int, int
; res = IsCalendarLeapYear(calId, year, era)
; calId : DWORD -> "int"
; year : DWORD -> "int"
; era : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procIsCalendarLeapYear = kernel32.NewProc("IsCalendarLeapYear")
)

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