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