ホーム › System.Ole › VarI4FromDisp
VarI4FromDisp
関数IDispatchオブジェクトの既定値をINTに変換する。
シグネチャ
// OLEAUT32.dll
#include <windows.h>
HRESULT VarI4FromDisp(
IDispatch* pdispIn,
DWORD lcid,
INT* plOut
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pdispIn | IDispatch* | in | 変換元のIDispatchポインタ。既定プロパティ値を変換する。NULL不可。 |
| lcid | DWORD | in | 値取得時に用いるロケールID。 |
| plOut | INT* | out | 変換後のINT(I4)値を受け取る出力ポインタ。NULL不可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLEAUT32.dll
#include <windows.h>
HRESULT VarI4FromDisp(
IDispatch* pdispIn,
DWORD lcid,
INT* plOut
);[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int VarI4FromDisp(
IntPtr pdispIn, // IDispatch*
uint lcid, // DWORD
out int plOut // INT* out
);<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function VarI4FromDisp(
pdispIn As IntPtr, ' IDispatch*
lcid As UInteger, ' DWORD
<Out> ByRef plOut As Integer ' INT* out
) As Integer
End Function' pdispIn : IDispatch*
' lcid : DWORD
' plOut : INT* out
Declare PtrSafe Function VarI4FromDisp Lib "oleaut32" ( _
ByVal pdispIn As LongPtr, _
ByVal lcid As Long, _
ByRef plOut As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
VarI4FromDisp = ctypes.windll.oleaut32.VarI4FromDisp
VarI4FromDisp.restype = ctypes.c_int
VarI4FromDisp.argtypes = [
ctypes.c_void_p, # pdispIn : IDispatch*
wintypes.DWORD, # lcid : DWORD
ctypes.POINTER(ctypes.c_int), # plOut : INT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLEAUT32.dll')
VarI4FromDisp = Fiddle::Function.new(
lib['VarI4FromDisp'],
[
Fiddle::TYPE_VOIDP, # pdispIn : IDispatch*
-Fiddle::TYPE_INT, # lcid : DWORD
Fiddle::TYPE_VOIDP, # plOut : INT* out
],
Fiddle::TYPE_INT)#[link(name = "oleaut32")]
extern "system" {
fn VarI4FromDisp(
pdispIn: *mut core::ffi::c_void, // IDispatch*
lcid: u32, // DWORD
plOut: *mut i32 // INT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLEAUT32.dll")]
public static extern int VarI4FromDisp(IntPtr pdispIn, uint lcid, out int plOut);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLEAUT32_VarI4FromDisp' -Namespace Win32 -PassThru
# $api::VarI4FromDisp(pdispIn, lcid, plOut)#uselib "OLEAUT32.dll"
#func global VarI4FromDisp "VarI4FromDisp" sptr, sptr, sptr
; VarI4FromDisp pdispIn, lcid, varptr(plOut) ; 戻り値は stat
; pdispIn : IDispatch* -> "sptr"
; lcid : DWORD -> "sptr"
; plOut : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "OLEAUT32.dll" #cfunc global VarI4FromDisp "VarI4FromDisp" sptr, int, var ; res = VarI4FromDisp(pdispIn, lcid, plOut) ; pdispIn : IDispatch* -> "sptr" ; lcid : DWORD -> "int" ; plOut : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OLEAUT32.dll" #cfunc global VarI4FromDisp "VarI4FromDisp" sptr, int, sptr ; res = VarI4FromDisp(pdispIn, lcid, varptr(plOut)) ; pdispIn : IDispatch* -> "sptr" ; lcid : DWORD -> "int" ; plOut : INT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT VarI4FromDisp(IDispatch* pdispIn, DWORD lcid, INT* plOut) #uselib "OLEAUT32.dll" #cfunc global VarI4FromDisp "VarI4FromDisp" intptr, int, var ; res = VarI4FromDisp(pdispIn, lcid, plOut) ; pdispIn : IDispatch* -> "intptr" ; lcid : DWORD -> "int" ; plOut : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT VarI4FromDisp(IDispatch* pdispIn, DWORD lcid, INT* plOut) #uselib "OLEAUT32.dll" #cfunc global VarI4FromDisp "VarI4FromDisp" intptr, int, intptr ; res = VarI4FromDisp(pdispIn, lcid, varptr(plOut)) ; pdispIn : IDispatch* -> "intptr" ; lcid : DWORD -> "int" ; plOut : INT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
procVarI4FromDisp = oleaut32.NewProc("VarI4FromDisp")
)
// pdispIn (IDispatch*), lcid (DWORD), plOut (INT* out)
r1, _, err := procVarI4FromDisp.Call(
uintptr(pdispIn),
uintptr(lcid),
uintptr(plOut),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction VarI4FromDisp(
pdispIn: Pointer; // IDispatch*
lcid: DWORD; // DWORD
plOut: Pointer // INT* out
): Integer; stdcall;
external 'OLEAUT32.dll' name 'VarI4FromDisp';result := DllCall("OLEAUT32\VarI4FromDisp"
, "Ptr", pdispIn ; IDispatch*
, "UInt", lcid ; DWORD
, "Ptr", plOut ; INT* out
, "Int") ; return: HRESULT●VarI4FromDisp(pdispIn, lcid, plOut) = DLL("OLEAUT32.dll", "int VarI4FromDisp(void*, dword, void*)")
# 呼び出し: VarI4FromDisp(pdispIn, lcid, plOut)
# pdispIn : IDispatch* -> "void*"
# lcid : DWORD -> "dword"
# plOut : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。