Win32 API 日本語リファレンス
ホームSystem.Com.StructuredStorage › CoGetInterfaceAndReleaseStream

CoGetInterfaceAndReleaseStream

関数
ストリームからインターフェイスを復元しストリームを解放する。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// OLE32.dll
#include <windows.h>

HRESULT CoGetInterfaceAndReleaseStream(
    IStream* pStm,
    const GUID* iid,
    void** ppv
);

パラメーター

名前方向
pStmIStream*in
iidGUID*in
ppvvoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

// OLE32.dll
#include <windows.h>

HRESULT CoGetInterfaceAndReleaseStream(
    IStream* pStm,
    const GUID* iid,
    void** ppv
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CoGetInterfaceAndReleaseStream(
    IntPtr pStm,   // IStream*
    ref Guid iid,   // GUID*
    IntPtr ppv   // void** out
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CoGetInterfaceAndReleaseStream(
    pStm As IntPtr,   ' IStream*
    ByRef iid As Guid,   ' GUID*
    ppv As IntPtr   ' void** out
) As Integer
End Function
' pStm : IStream*
' iid : GUID*
' ppv : void** out
Declare PtrSafe Function CoGetInterfaceAndReleaseStream Lib "ole32" ( _
    ByVal pStm As LongPtr, _
    ByVal iid As LongPtr, _
    ByVal ppv As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CoGetInterfaceAndReleaseStream = ctypes.windll.ole32.CoGetInterfaceAndReleaseStream
CoGetInterfaceAndReleaseStream.restype = ctypes.c_int
CoGetInterfaceAndReleaseStream.argtypes = [
    ctypes.c_void_p,  # pStm : IStream*
    ctypes.c_void_p,  # iid : GUID*
    ctypes.c_void_p,  # ppv : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OLE32.dll')
CoGetInterfaceAndReleaseStream = Fiddle::Function.new(
  lib['CoGetInterfaceAndReleaseStream'],
  [
    Fiddle::TYPE_VOIDP,  # pStm : IStream*
    Fiddle::TYPE_VOIDP,  # iid : GUID*
    Fiddle::TYPE_VOIDP,  # ppv : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "ole32")]
extern "system" {
    fn CoGetInterfaceAndReleaseStream(
        pStm: *mut core::ffi::c_void,  // IStream*
        iid: *const GUID,  // GUID*
        ppv: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OLE32.dll")]
public static extern int CoGetInterfaceAndReleaseStream(IntPtr pStm, ref Guid iid, IntPtr ppv);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_CoGetInterfaceAndReleaseStream' -Namespace Win32 -PassThru
# $api::CoGetInterfaceAndReleaseStream(pStm, iid, ppv)
#uselib "OLE32.dll"
#func global CoGetInterfaceAndReleaseStream "CoGetInterfaceAndReleaseStream" sptr, sptr, sptr
; CoGetInterfaceAndReleaseStream pStm, varptr(iid), ppv   ; 戻り値は stat
; pStm : IStream* -> "sptr"
; iid : GUID* -> "sptr"
; ppv : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "OLE32.dll"
#cfunc global CoGetInterfaceAndReleaseStream "CoGetInterfaceAndReleaseStream" sptr, var, sptr
; res = CoGetInterfaceAndReleaseStream(pStm, iid, ppv)
; pStm : IStream* -> "sptr"
; iid : GUID* -> "var"
; ppv : void** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CoGetInterfaceAndReleaseStream(IStream* pStm, GUID* iid, void** ppv)
#uselib "OLE32.dll"
#cfunc global CoGetInterfaceAndReleaseStream "CoGetInterfaceAndReleaseStream" intptr, var, intptr
; res = CoGetInterfaceAndReleaseStream(pStm, iid, ppv)
; pStm : IStream* -> "intptr"
; iid : GUID* -> "var"
; ppv : void** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procCoGetInterfaceAndReleaseStream = ole32.NewProc("CoGetInterfaceAndReleaseStream")
)

// pStm (IStream*), iid (GUID*), ppv (void** out)
r1, _, err := procCoGetInterfaceAndReleaseStream.Call(
	uintptr(pStm),
	uintptr(iid),
	uintptr(ppv),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CoGetInterfaceAndReleaseStream(
  pStm: Pointer;   // IStream*
  iid: PGUID;   // GUID*
  ppv: Pointer   // void** out
): Integer; stdcall;
  external 'OLE32.dll' name 'CoGetInterfaceAndReleaseStream';
result := DllCall("OLE32\CoGetInterfaceAndReleaseStream"
    , "Ptr", pStm   ; IStream*
    , "Ptr", iid   ; GUID*
    , "Ptr", ppv   ; void** out
    , "Int")   ; return: HRESULT
●CoGetInterfaceAndReleaseStream(pStm, iid, ppv) = DLL("OLE32.dll", "int CoGetInterfaceAndReleaseStream(void*, void*, void*)")
# 呼び出し: CoGetInterfaceAndReleaseStream(pStm, iid, ppv)
# pStm : IStream* -> "void*"
# iid : GUID* -> "void*"
# ppv : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。