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