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

AdjustCalendarDate

関数
暦日時を指定単位で増減調整する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

BOOL AdjustCalendarDate(
    CALDATETIME* lpCalDateTime,
    CALDATETIME_DATEUNIT calUnit,
    INT amount
);

パラメーター

名前方向
lpCalDateTimeCALDATETIME*inout
calUnitCALDATETIME_DATEUNITin
amountINTin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

AdjustCalendarDate = ctypes.windll.kernel32.AdjustCalendarDate
AdjustCalendarDate.restype = wintypes.BOOL
AdjustCalendarDate.argtypes = [
    ctypes.c_void_p,  # lpCalDateTime : CALDATETIME* in/out
    ctypes.c_int,  # calUnit : CALDATETIME_DATEUNIT
    ctypes.c_int,  # amount : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procAdjustCalendarDate = kernel32.NewProc("AdjustCalendarDate")
)

// lpCalDateTime (CALDATETIME* in/out), calUnit (CALDATETIME_DATEUNIT), amount (INT)
r1, _, err := procAdjustCalendarDate.Call(
	uintptr(lpCalDateTime),
	uintptr(calUnit),
	uintptr(amount),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function AdjustCalendarDate(
  lpCalDateTime: Pointer;   // CALDATETIME* in/out
  calUnit: Integer;   // CALDATETIME_DATEUNIT
  amount: Integer   // INT
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'AdjustCalendarDate';
result := DllCall("KERNEL32\AdjustCalendarDate"
    , "Ptr", lpCalDateTime   ; CALDATETIME* in/out
    , "Int", calUnit   ; CALDATETIME_DATEUNIT
    , "Int", amount   ; INT
    , "Int")   ; return: BOOL
●AdjustCalendarDate(lpCalDateTime, calUnit, amount) = DLL("KERNEL32.dll", "bool AdjustCalendarDate(void*, int, int)")
# 呼び出し: AdjustCalendarDate(lpCalDateTime, calUnit, amount)
# lpCalDateTime : CALDATETIME* in/out -> "void*"
# calUnit : CALDATETIME_DATEUNIT -> "int"
# amount : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。