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