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