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

VarUI4FromDate

関数
DATE型の日付値を符号なし4バイト整数に変換する。
DLLOLEAUT32.dll呼出規約winapi

シグネチャ

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

HRESULT VarUI4FromDate(
    DOUBLE dateIn,
    DWORD* pulOut
);

パラメーター

名前方向
dateInDOUBLEin
pulOutDWORD*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT VarUI4FromDate(
    DOUBLE dateIn,
    DWORD* pulOut
);
[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int VarUI4FromDate(
    double dateIn,   // DOUBLE
    out uint pulOut   // DWORD* out
);
<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function VarUI4FromDate(
    dateIn As Double,   ' DOUBLE
    <Out> ByRef pulOut As UInteger   ' DWORD* out
) As Integer
End Function
' dateIn : DOUBLE
' pulOut : DWORD* out
Declare PtrSafe Function VarUI4FromDate Lib "oleaut32" ( _
    ByVal dateIn As Double, _
    ByRef pulOut As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

VarUI4FromDate = ctypes.windll.oleaut32.VarUI4FromDate
VarUI4FromDate.restype = ctypes.c_int
VarUI4FromDate.argtypes = [
    ctypes.c_double,  # dateIn : DOUBLE
    ctypes.POINTER(wintypes.DWORD),  # pulOut : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
	procVarUI4FromDate = oleaut32.NewProc("VarUI4FromDate")
)

// dateIn (DOUBLE), pulOut (DWORD* out)
r1, _, err := procVarUI4FromDate.Call(
	uintptr(math.Float64bits(dateIn)),
	uintptr(pulOut),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。
function VarUI4FromDate(
  dateIn: Double;   // DOUBLE
  pulOut: Pointer   // DWORD* out
): Integer; stdcall;
  external 'OLEAUT32.dll' name 'VarUI4FromDate';
result := DllCall("OLEAUT32\VarUI4FromDate"
    , "Double", dateIn   ; DOUBLE
    , "Ptr", pulOut   ; DWORD* out
    , "Int")   ; return: HRESULT
●VarUI4FromDate(dateIn, pulOut) = DLL("OLEAUT32.dll", "int VarUI4FromDate(double, void*)")
# 呼び出し: VarUI4FromDate(dateIn, pulOut)
# dateIn : DOUBLE -> "double"
# pulOut : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。