ホーム › System.Ole › VarDecFromR4
VarDecFromR4
関数単精度浮動小数点数をDECIMAL型に変換する。
シグネチャ
// OLEAUT32.dll
#include <windows.h>
HRESULT VarDecFromR4(
FLOAT fltIn,
DECIMAL* pdecOut
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| fltIn | FLOAT | in |
| pdecOut | DECIMAL* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLEAUT32.dll
#include <windows.h>
HRESULT VarDecFromR4(
FLOAT fltIn,
DECIMAL* pdecOut
);[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int VarDecFromR4(
float fltIn, // FLOAT
IntPtr pdecOut // DECIMAL* out
);<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function VarDecFromR4(
fltIn As Single, ' FLOAT
pdecOut As IntPtr ' DECIMAL* out
) As Integer
End Function' fltIn : FLOAT
' pdecOut : DECIMAL* out
Declare PtrSafe Function VarDecFromR4 Lib "oleaut32" ( _
ByVal fltIn As Single, _
ByVal pdecOut As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
VarDecFromR4 = ctypes.windll.oleaut32.VarDecFromR4
VarDecFromR4.restype = ctypes.c_int
VarDecFromR4.argtypes = [
ctypes.c_float, # fltIn : FLOAT
ctypes.c_void_p, # pdecOut : DECIMAL* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLEAUT32.dll')
VarDecFromR4 = Fiddle::Function.new(
lib['VarDecFromR4'],
[
Fiddle::TYPE_FLOAT, # fltIn : FLOAT
Fiddle::TYPE_VOIDP, # pdecOut : DECIMAL* out
],
Fiddle::TYPE_INT)#[link(name = "oleaut32")]
extern "system" {
fn VarDecFromR4(
fltIn: f32, // FLOAT
pdecOut: *mut DECIMAL // DECIMAL* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLEAUT32.dll")]
public static extern int VarDecFromR4(float fltIn, IntPtr pdecOut);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLEAUT32_VarDecFromR4' -Namespace Win32 -PassThru
# $api::VarDecFromR4(fltIn, pdecOut)#uselib "OLEAUT32.dll"
#func global VarDecFromR4 "VarDecFromR4" float, sptr
; VarDecFromR4 fltIn, varptr(pdecOut) ; 戻り値は stat
; fltIn : FLOAT -> "float"
; pdecOut : DECIMAL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "OLEAUT32.dll" #cfunc global VarDecFromR4 "VarDecFromR4" float, var ; res = VarDecFromR4(fltIn, pdecOut) ; fltIn : FLOAT -> "float" ; pdecOut : DECIMAL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OLEAUT32.dll" #cfunc global VarDecFromR4 "VarDecFromR4" float, sptr ; res = VarDecFromR4(fltIn, varptr(pdecOut)) ; fltIn : FLOAT -> "float" ; pdecOut : DECIMAL* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT VarDecFromR4(FLOAT fltIn, DECIMAL* pdecOut) #uselib "OLEAUT32.dll" #cfunc global VarDecFromR4 "VarDecFromR4" float, var ; res = VarDecFromR4(fltIn, pdecOut) ; fltIn : FLOAT -> "float" ; pdecOut : DECIMAL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT VarDecFromR4(FLOAT fltIn, DECIMAL* pdecOut) #uselib "OLEAUT32.dll" #cfunc global VarDecFromR4 "VarDecFromR4" float, intptr ; res = VarDecFromR4(fltIn, varptr(pdecOut)) ; fltIn : FLOAT -> "float" ; pdecOut : DECIMAL* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
procVarDecFromR4 = oleaut32.NewProc("VarDecFromR4")
)
// fltIn (FLOAT), pdecOut (DECIMAL* out)
r1, _, err := procVarDecFromR4.Call(
uintptr(math.Float32bits(fltIn)),
uintptr(pdecOut),
)
_ = 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 VarDecFromR4(
fltIn: Single; // FLOAT
pdecOut: Pointer // DECIMAL* out
): Integer; stdcall;
external 'OLEAUT32.dll' name 'VarDecFromR4';result := DllCall("OLEAUT32\VarDecFromR4"
, "Float", fltIn ; FLOAT
, "Ptr", pdecOut ; DECIMAL* out
, "Int") ; return: HRESULT●VarDecFromR4(fltIn, pdecOut) = DLL("OLEAUT32.dll", "int VarDecFromR4(float, void*)")
# 呼び出し: VarDecFromR4(fltIn, pdecOut)
# fltIn : FLOAT -> "float"
# pdecOut : DECIMAL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。