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