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

VarDecCmpR8

関数
DECIMAL値と倍精度浮動小数点数を比較する。
DLLOLEAUT32.dll呼出規約winapi

シグネチャ

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

VARCMP VarDecCmpR8(
    DECIMAL* pdecLeft,
    DOUBLE dblRight
);

パラメーター

名前方向説明
pdecLeftDECIMAL*in比較の左オペランドDECIMALへのポインタ。
dblRightDOUBLEin比較対象の倍精度浮動小数点数(DOUBLE)。戻り値VARCMPで大小関係を返す。

戻り値の型: VARCMP

各言語での呼び出し定義

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

VARCMP VarDecCmpR8(
    DECIMAL* pdecLeft,
    DOUBLE dblRight
);
[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern uint VarDecCmpR8(
    IntPtr pdecLeft,   // DECIMAL*
    double dblRight   // DOUBLE
);
<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function VarDecCmpR8(
    pdecLeft As IntPtr,   ' DECIMAL*
    dblRight As Double   ' DOUBLE
) As UInteger
End Function
' pdecLeft : DECIMAL*
' dblRight : DOUBLE
Declare PtrSafe Function VarDecCmpR8 Lib "oleaut32" ( _
    ByVal pdecLeft As LongPtr, _
    ByVal dblRight As Double) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

VarDecCmpR8 = ctypes.windll.oleaut32.VarDecCmpR8
VarDecCmpR8.restype = wintypes.DWORD
VarDecCmpR8.argtypes = [
    ctypes.c_void_p,  # pdecLeft : DECIMAL*
    ctypes.c_double,  # dblRight : DOUBLE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
	procVarDecCmpR8 = oleaut32.NewProc("VarDecCmpR8")
)

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