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