ホーム › System.Ole › SafeArrayCreateVector
SafeArrayCreateVector
関数1次元のセーフ配列(ベクター)を生成する。
シグネチャ
// OLEAUT32.dll
#include <windows.h>
SAFEARRAY* SafeArrayCreateVector(
VARENUM vt,
INT lLbound,
DWORD cElements
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| vt | VARENUM | in |
| lLbound | INT | in |
| cElements | DWORD | in |
戻り値の型: SAFEARRAY*
各言語での呼び出し定義
// OLEAUT32.dll
#include <windows.h>
SAFEARRAY* SafeArrayCreateVector(
VARENUM vt,
INT lLbound,
DWORD cElements
);[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern IntPtr SafeArrayCreateVector(
ushort vt, // VARENUM
int lLbound, // INT
uint cElements // DWORD
);<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function SafeArrayCreateVector(
vt As UShort, ' VARENUM
lLbound As Integer, ' INT
cElements As UInteger ' DWORD
) As IntPtr
End Function' vt : VARENUM
' lLbound : INT
' cElements : DWORD
Declare PtrSafe Function SafeArrayCreateVector Lib "oleaut32" ( _
ByVal vt As Integer, _
ByVal lLbound As Long, _
ByVal cElements As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SafeArrayCreateVector = ctypes.windll.oleaut32.SafeArrayCreateVector
SafeArrayCreateVector.restype = ctypes.c_void_p
SafeArrayCreateVector.argtypes = [
ctypes.c_ushort, # vt : VARENUM
ctypes.c_int, # lLbound : INT
wintypes.DWORD, # cElements : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLEAUT32.dll')
SafeArrayCreateVector = Fiddle::Function.new(
lib['SafeArrayCreateVector'],
[
-Fiddle::TYPE_SHORT, # vt : VARENUM
Fiddle::TYPE_INT, # lLbound : INT
-Fiddle::TYPE_INT, # cElements : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "oleaut32")]
extern "system" {
fn SafeArrayCreateVector(
vt: u16, // VARENUM
lLbound: i32, // INT
cElements: u32 // DWORD
) -> *mut SAFEARRAY;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLEAUT32.dll")]
public static extern IntPtr SafeArrayCreateVector(ushort vt, int lLbound, uint cElements);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLEAUT32_SafeArrayCreateVector' -Namespace Win32 -PassThru
# $api::SafeArrayCreateVector(vt, lLbound, cElements)#uselib "OLEAUT32.dll"
#func global SafeArrayCreateVector "SafeArrayCreateVector" sptr, sptr, sptr
; SafeArrayCreateVector vt, lLbound, cElements ; 戻り値は stat
; vt : VARENUM -> "sptr"
; lLbound : INT -> "sptr"
; cElements : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLEAUT32.dll"
#cfunc global SafeArrayCreateVector "SafeArrayCreateVector" int, int, int
; res = SafeArrayCreateVector(vt, lLbound, cElements)
; vt : VARENUM -> "int"
; lLbound : INT -> "int"
; cElements : DWORD -> "int"; SAFEARRAY* SafeArrayCreateVector(VARENUM vt, INT lLbound, DWORD cElements)
#uselib "OLEAUT32.dll"
#cfunc global SafeArrayCreateVector "SafeArrayCreateVector" int, int, int
; res = SafeArrayCreateVector(vt, lLbound, cElements)
; vt : VARENUM -> "int"
; lLbound : INT -> "int"
; cElements : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
procSafeArrayCreateVector = oleaut32.NewProc("SafeArrayCreateVector")
)
// vt (VARENUM), lLbound (INT), cElements (DWORD)
r1, _, err := procSafeArrayCreateVector.Call(
uintptr(vt),
uintptr(lLbound),
uintptr(cElements),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SAFEARRAY*function SafeArrayCreateVector(
vt: Word; // VARENUM
lLbound: Integer; // INT
cElements: DWORD // DWORD
): Pointer; stdcall;
external 'OLEAUT32.dll' name 'SafeArrayCreateVector';result := DllCall("OLEAUT32\SafeArrayCreateVector"
, "UShort", vt ; VARENUM
, "Int", lLbound ; INT
, "UInt", cElements ; DWORD
, "Ptr") ; return: SAFEARRAY*●SafeArrayCreateVector(vt, lLbound, cElements) = DLL("OLEAUT32.dll", "void* SafeArrayCreateVector(int, int, dword)")
# 呼び出し: SafeArrayCreateVector(vt, lLbound, cElements)
# vt : VARENUM -> "int"
# lLbound : INT -> "int"
# cElements : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。