Win32 API 日本語リファレンス
ホームSystem.Ole › OleLoadFromStream

OleLoadFromStream

関数
ストリームからオブジェクトを読み込み初期化する。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT OleLoadFromStream(
    IStream* pStm,
    const GUID* iidInterface,
    void** ppvObj
);

パラメーター

名前方向
pStmIStream*in
iidInterfaceGUID*in
ppvObjvoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

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

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procOleLoadFromStream = ole32.NewProc("OleLoadFromStream")
)

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