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

VarCyAdd

関数
2つの通貨型(CY)値を加算し結果を返す。
DLLOLEAUT32.dll呼出規約winapi

シグネチャ

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

HRESULT VarCyAdd(
    CY cyLeft,
    CY cyRight,
    CY* pcyResult
);

パラメーター

名前方向
cyLeftCYin
cyRightCYin
pcyResultCY*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

VarCyAdd = ctypes.windll.oleaut32.VarCyAdd
VarCyAdd.restype = ctypes.c_int
VarCyAdd.argtypes = [
    CY,  # cyLeft : CY
    CY,  # cyRight : CY
    ctypes.c_void_p,  # pcyResult : CY* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
	procVarCyAdd = oleaut32.NewProc("VarCyAdd")
)

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