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

ConvertCalDateTimeToSystemTime

関数
暦日時をシステム時刻へ変換する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

BOOL ConvertCalDateTimeToSystemTime(
    const CALDATETIME* lpCalDateTime,
    SYSTEMTIME* lpSysTime
);

パラメーター

名前方向説明
lpCalDateTimeCALDATETIME*in変換元の暦日時を保持するCALDATETIME構造体へのポインター。
lpSysTimeSYSTEMTIME*out変換結果のグレゴリオ暦日時を受け取るSYSTEMTIME構造体へのポインター。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

ConvertCalDateTimeToSystemTime = ctypes.windll.kernel32.ConvertCalDateTimeToSystemTime
ConvertCalDateTimeToSystemTime.restype = wintypes.BOOL
ConvertCalDateTimeToSystemTime.argtypes = [
    ctypes.c_void_p,  # lpCalDateTime : CALDATETIME*
    ctypes.c_void_p,  # lpSysTime : SYSTEMTIME* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procConvertCalDateTimeToSystemTime = kernel32.NewProc("ConvertCalDateTimeToSystemTime")
)

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

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

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

foreign import stdcall safe "ConvertCalDateTimeToSystemTime"
  c_ConvertCalDateTimeToSystemTime :: Ptr () -> Ptr () -> IO CInt
-- lpCalDateTime : CALDATETIME* -> Ptr ()
-- lpSysTime : SYSTEMTIME* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let convertcaldatetimetosystemtime =
  foreign "ConvertCalDateTimeToSystemTime"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* lpCalDateTime : CALDATETIME* -> (ptr void) *)
(* lpSysTime : SYSTEMTIME* 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 ("ConvertCalDateTimeToSystemTime" convert-cal-date-time-to-system-time :convention :stdcall) :int32
  (lp-cal-date-time :pointer)   ; CALDATETIME*
  (lp-sys-time :pointer))   ; SYSTEMTIME* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ConvertCalDateTimeToSystemTime = Win32::API::More->new('KERNEL32',
    'BOOL ConvertCalDateTimeToSystemTime(LPVOID lpCalDateTime, LPVOID lpSysTime)');
# my $ret = $ConvertCalDateTimeToSystemTime->Call($lpCalDateTime, $lpSysTime);
# lpCalDateTime : CALDATETIME* -> LPVOID
# lpSysTime : SYSTEMTIME* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型