ホーム › System.Com.Marshal › CoMarshalInterface
CoMarshalInterface
関数インターフェイスポインタをストリームへマーシャリングして書き込む。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT CoMarshalInterface(
IStream* pStm,
const GUID* riid,
IUnknown* pUnk,
DWORD dwDestContext,
void* pvDestContext, // optional
DWORD mshlflags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pStm | IStream* | in |
| riid | GUID* | in |
| pUnk | IUnknown* | in |
| dwDestContext | DWORD | in |
| pvDestContext | void* | inoptional |
| mshlflags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT CoMarshalInterface(
IStream* pStm,
const GUID* riid,
IUnknown* pUnk,
DWORD dwDestContext,
void* pvDestContext, // optional
DWORD mshlflags
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CoMarshalInterface(
IntPtr pStm, // IStream*
ref Guid riid, // GUID*
IntPtr pUnk, // IUnknown*
uint dwDestContext, // DWORD
IntPtr pvDestContext, // void* optional
uint mshlflags // DWORD
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CoMarshalInterface(
pStm As IntPtr, ' IStream*
ByRef riid As Guid, ' GUID*
pUnk As IntPtr, ' IUnknown*
dwDestContext As UInteger, ' DWORD
pvDestContext As IntPtr, ' void* optional
mshlflags As UInteger ' DWORD
) As Integer
End Function' pStm : IStream*
' riid : GUID*
' pUnk : IUnknown*
' dwDestContext : DWORD
' pvDestContext : void* optional
' mshlflags : DWORD
Declare PtrSafe Function CoMarshalInterface Lib "ole32" ( _
ByVal pStm As LongPtr, _
ByVal riid As LongPtr, _
ByVal pUnk As LongPtr, _
ByVal dwDestContext As Long, _
ByVal pvDestContext As LongPtr, _
ByVal mshlflags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CoMarshalInterface = ctypes.windll.ole32.CoMarshalInterface
CoMarshalInterface.restype = ctypes.c_int
CoMarshalInterface.argtypes = [
ctypes.c_void_p, # pStm : IStream*
ctypes.c_void_p, # riid : GUID*
ctypes.c_void_p, # pUnk : IUnknown*
wintypes.DWORD, # dwDestContext : DWORD
ctypes.POINTER(None), # pvDestContext : void* optional
wintypes.DWORD, # mshlflags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
CoMarshalInterface = Fiddle::Function.new(
lib['CoMarshalInterface'],
[
Fiddle::TYPE_VOIDP, # pStm : IStream*
Fiddle::TYPE_VOIDP, # riid : GUID*
Fiddle::TYPE_VOIDP, # pUnk : IUnknown*
-Fiddle::TYPE_INT, # dwDestContext : DWORD
Fiddle::TYPE_VOIDP, # pvDestContext : void* optional
-Fiddle::TYPE_INT, # mshlflags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn CoMarshalInterface(
pStm: *mut core::ffi::c_void, // IStream*
riid: *const GUID, // GUID*
pUnk: *mut core::ffi::c_void, // IUnknown*
dwDestContext: u32, // DWORD
pvDestContext: *mut (), // void* optional
mshlflags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int CoMarshalInterface(IntPtr pStm, ref Guid riid, IntPtr pUnk, uint dwDestContext, IntPtr pvDestContext, uint mshlflags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_CoMarshalInterface' -Namespace Win32 -PassThru
# $api::CoMarshalInterface(pStm, riid, pUnk, dwDestContext, pvDestContext, mshlflags)#uselib "OLE32.dll"
#func global CoMarshalInterface "CoMarshalInterface" sptr, sptr, sptr, sptr, sptr, sptr
; CoMarshalInterface pStm, varptr(riid), pUnk, dwDestContext, pvDestContext, mshlflags ; 戻り値は stat
; pStm : IStream* -> "sptr"
; riid : GUID* -> "sptr"
; pUnk : IUnknown* -> "sptr"
; dwDestContext : DWORD -> "sptr"
; pvDestContext : void* optional -> "sptr"
; mshlflags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "OLE32.dll" #cfunc global CoMarshalInterface "CoMarshalInterface" sptr, var, sptr, int, sptr, int ; res = CoMarshalInterface(pStm, riid, pUnk, dwDestContext, pvDestContext, mshlflags) ; pStm : IStream* -> "sptr" ; riid : GUID* -> "var" ; pUnk : IUnknown* -> "sptr" ; dwDestContext : DWORD -> "int" ; pvDestContext : void* optional -> "sptr" ; mshlflags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OLE32.dll" #cfunc global CoMarshalInterface "CoMarshalInterface" sptr, sptr, sptr, int, sptr, int ; res = CoMarshalInterface(pStm, varptr(riid), pUnk, dwDestContext, pvDestContext, mshlflags) ; pStm : IStream* -> "sptr" ; riid : GUID* -> "sptr" ; pUnk : IUnknown* -> "sptr" ; dwDestContext : DWORD -> "int" ; pvDestContext : void* optional -> "sptr" ; mshlflags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CoMarshalInterface(IStream* pStm, GUID* riid, IUnknown* pUnk, DWORD dwDestContext, void* pvDestContext, DWORD mshlflags) #uselib "OLE32.dll" #cfunc global CoMarshalInterface "CoMarshalInterface" intptr, var, intptr, int, intptr, int ; res = CoMarshalInterface(pStm, riid, pUnk, dwDestContext, pvDestContext, mshlflags) ; pStm : IStream* -> "intptr" ; riid : GUID* -> "var" ; pUnk : IUnknown* -> "intptr" ; dwDestContext : DWORD -> "int" ; pvDestContext : void* optional -> "intptr" ; mshlflags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CoMarshalInterface(IStream* pStm, GUID* riid, IUnknown* pUnk, DWORD dwDestContext, void* pvDestContext, DWORD mshlflags) #uselib "OLE32.dll" #cfunc global CoMarshalInterface "CoMarshalInterface" intptr, intptr, intptr, int, intptr, int ; res = CoMarshalInterface(pStm, varptr(riid), pUnk, dwDestContext, pvDestContext, mshlflags) ; pStm : IStream* -> "intptr" ; riid : GUID* -> "intptr" ; pUnk : IUnknown* -> "intptr" ; dwDestContext : DWORD -> "int" ; pvDestContext : void* optional -> "intptr" ; mshlflags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procCoMarshalInterface = ole32.NewProc("CoMarshalInterface")
)
// pStm (IStream*), riid (GUID*), pUnk (IUnknown*), dwDestContext (DWORD), pvDestContext (void* optional), mshlflags (DWORD)
r1, _, err := procCoMarshalInterface.Call(
uintptr(pStm),
uintptr(riid),
uintptr(pUnk),
uintptr(dwDestContext),
uintptr(pvDestContext),
uintptr(mshlflags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CoMarshalInterface(
pStm: Pointer; // IStream*
riid: PGUID; // GUID*
pUnk: Pointer; // IUnknown*
dwDestContext: DWORD; // DWORD
pvDestContext: Pointer; // void* optional
mshlflags: DWORD // DWORD
): Integer; stdcall;
external 'OLE32.dll' name 'CoMarshalInterface';result := DllCall("OLE32\CoMarshalInterface"
, "Ptr", pStm ; IStream*
, "Ptr", riid ; GUID*
, "Ptr", pUnk ; IUnknown*
, "UInt", dwDestContext ; DWORD
, "Ptr", pvDestContext ; void* optional
, "UInt", mshlflags ; DWORD
, "Int") ; return: HRESULT●CoMarshalInterface(pStm, riid, pUnk, dwDestContext, pvDestContext, mshlflags) = DLL("OLE32.dll", "int CoMarshalInterface(void*, void*, void*, dword, void*, dword)")
# 呼び出し: CoMarshalInterface(pStm, riid, pUnk, dwDestContext, pvDestContext, mshlflags)
# pStm : IStream* -> "void*"
# riid : GUID* -> "void*"
# pUnk : IUnknown* -> "void*"
# dwDestContext : DWORD -> "dword"
# pvDestContext : void* optional -> "void*"
# mshlflags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。