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

GetCalendarSupportedDateRange

関数
暦がサポートする日付範囲を取得する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

BOOL GetCalendarSupportedDateRange(
    DWORD Calendar,
    CALDATETIME* lpCalMinDateTime,
    CALDATETIME* lpCalMaxDateTime
);

パラメーター

名前方向説明
CalendarDWORDin対象の暦を示すカレンダー識別子(CAL_GREGORIAN等)。
lpCalMinDateTimeCALDATETIME*outサポートされる最小日時を受け取るCALDATETIME構造体へのポインター。
lpCalMaxDateTimeCALDATETIME*outサポートされる最大日時を受け取るCALDATETIME構造体へのポインター。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

GetCalendarSupportedDateRange = ctypes.windll.kernel32.GetCalendarSupportedDateRange
GetCalendarSupportedDateRange.restype = wintypes.BOOL
GetCalendarSupportedDateRange.argtypes = [
    wintypes.DWORD,  # Calendar : DWORD
    ctypes.c_void_p,  # lpCalMinDateTime : CALDATETIME* out
    ctypes.c_void_p,  # lpCalMaxDateTime : CALDATETIME* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetCalendarSupportedDateRange = kernel32.NewProc("GetCalendarSupportedDateRange")
)

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

extern "kernel32" fn GetCalendarSupportedDateRange(
    Calendar: u32, // DWORD
    lpCalMinDateTime: [*c]CALDATETIME, // CALDATETIME* out
    lpCalMaxDateTime: [*c]CALDATETIME // CALDATETIME* out
) callconv(std.os.windows.WINAPI) i32;
proc GetCalendarSupportedDateRange(
    Calendar: uint32,  # DWORD
    lpCalMinDateTime: ptr CALDATETIME,  # CALDATETIME* out
    lpCalMaxDateTime: ptr CALDATETIME  # CALDATETIME* out
): int32 {.importc: "GetCalendarSupportedDateRange", stdcall, dynlib: "KERNEL32.dll".}
pragma(lib, "kernel32");
extern(Windows)
int GetCalendarSupportedDateRange(
    uint Calendar,   // DWORD
    CALDATETIME* lpCalMinDateTime,   // CALDATETIME* out
    CALDATETIME* lpCalMaxDateTime   // CALDATETIME* out
);
ccall((:GetCalendarSupportedDateRange, "KERNEL32.dll"), stdcall, Int32,
      (UInt32, Ptr{CALDATETIME}, Ptr{CALDATETIME}),
      Calendar, lpCalMinDateTime, lpCalMaxDateTime)
# Calendar : DWORD -> UInt32
# lpCalMinDateTime : CALDATETIME* out -> Ptr{CALDATETIME}
# lpCalMaxDateTime : CALDATETIME* out -> Ptr{CALDATETIME}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetCalendarSupportedDateRange(
    uint32_t Calendar,
    void* lpCalMinDateTime,
    void* lpCalMaxDateTime);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.GetCalendarSupportedDateRange(Calendar, lpCalMinDateTime, lpCalMaxDateTime)
-- Calendar : DWORD
-- lpCalMinDateTime : CALDATETIME* out
-- lpCalMaxDateTime : CALDATETIME* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const GetCalendarSupportedDateRange = lib.func('__stdcall', 'GetCalendarSupportedDateRange', 'int32_t', ['uint32_t', 'void *', 'void *']);
// GetCalendarSupportedDateRange(Calendar, lpCalMinDateTime, lpCalMaxDateTime)
// Calendar : DWORD -> 'uint32_t'
// lpCalMinDateTime : CALDATETIME* out -> 'void *'
// lpCalMaxDateTime : CALDATETIME* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  GetCalendarSupportedDateRange: { parameters: ["u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetCalendarSupportedDateRange(Calendar, lpCalMinDateTime, lpCalMaxDateTime)
// Calendar : DWORD -> "u32"
// lpCalMinDateTime : CALDATETIME* out -> "pointer"
// lpCalMaxDateTime : CALDATETIME* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetCalendarSupportedDateRange(
    uint32_t Calendar,
    void* lpCalMinDateTime,
    void* lpCalMaxDateTime);
C, "KERNEL32.dll");
// $ffi->GetCalendarSupportedDateRange(Calendar, lpCalMinDateTime, lpCalMaxDateTime);
// Calendar : DWORD
// lpCalMinDateTime : CALDATETIME* out
// lpCalMaxDateTime : CALDATETIME* 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 GetCalendarSupportedDateRange(
        int Calendar,   // DWORD
        Pointer lpCalMinDateTime,   // CALDATETIME* out
        Pointer lpCalMaxDateTime   // CALDATETIME* out
    );
}
@[Link("kernel32")]
lib LibKERNEL32
  fun GetCalendarSupportedDateRange = GetCalendarSupportedDateRange(
    Calendar : UInt32,   # DWORD
    lpCalMinDateTime : CALDATETIME*,   # CALDATETIME* out
    lpCalMaxDateTime : CALDATETIME*   # CALDATETIME* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

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

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

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

(cffi:defcfun ("GetCalendarSupportedDateRange" get-calendar-supported-date-range :convention :stdcall) :int32
  (calendar :uint32)   ; DWORD
  (lp-cal-min-date-time :pointer)   ; CALDATETIME* out
  (lp-cal-max-date-time :pointer))   ; CALDATETIME* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetCalendarSupportedDateRange = Win32::API::More->new('KERNEL32',
    'BOOL GetCalendarSupportedDateRange(DWORD Calendar, LPVOID lpCalMinDateTime, LPVOID lpCalMaxDateTime)');
# my $ret = $GetCalendarSupportedDateRange->Call($Calendar, $lpCalMinDateTime, $lpCalMaxDateTime);
# Calendar : DWORD -> DWORD
# lpCalMinDateTime : CALDATETIME* out -> LPVOID
# lpCalMaxDateTime : CALDATETIME* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型