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

VarDecRound

関数
DECIMAL値を指定した小数桁数に丸める。
DLLOLEAUT32.dll呼出規約winapi

シグネチャ

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

HRESULT VarDecRound(
    DECIMAL* pdecIn,
    INT cDecimals,
    DECIMAL* pdecResult
);

パラメーター

名前方向
pdecInDECIMAL*in
cDecimalsINTin
pdecResultDECIMAL*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT VarDecRound(
    DECIMAL* pdecIn,
    INT cDecimals,
    DECIMAL* pdecResult
);
[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int VarDecRound(
    IntPtr pdecIn,   // DECIMAL*
    int cDecimals,   // INT
    IntPtr pdecResult   // DECIMAL* out
);
<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function VarDecRound(
    pdecIn As IntPtr,   ' DECIMAL*
    cDecimals As Integer,   ' INT
    pdecResult As IntPtr   ' DECIMAL* out
) As Integer
End Function
' pdecIn : DECIMAL*
' cDecimals : INT
' pdecResult : DECIMAL* out
Declare PtrSafe Function VarDecRound Lib "oleaut32" ( _
    ByVal pdecIn As LongPtr, _
    ByVal cDecimals As Long, _
    ByVal pdecResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

VarDecRound = ctypes.windll.oleaut32.VarDecRound
VarDecRound.restype = ctypes.c_int
VarDecRound.argtypes = [
    ctypes.c_void_p,  # pdecIn : DECIMAL*
    ctypes.c_int,  # cDecimals : INT
    ctypes.c_void_p,  # pdecResult : DECIMAL* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
	procVarDecRound = oleaut32.NewProc("VarDecRound")
)

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