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