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

CoRegisterChannelHook

関数
COM呼び出しチャネルに対するフックを登録する。
DLLole32.dll呼出規約winapi

シグネチャ

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

HRESULT CoRegisterChannelHook(
    const GUID* ExtensionUuid,
    IChannelHook* pChannelHook
);

パラメーター

名前方向
ExtensionUuidGUID*in
pChannelHookIChannelHook*in

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

CoRegisterChannelHook = ctypes.windll.ole32.CoRegisterChannelHook
CoRegisterChannelHook.restype = ctypes.c_int
CoRegisterChannelHook.argtypes = [
    ctypes.c_void_p,  # ExtensionUuid : GUID*
    ctypes.c_void_p,  # pChannelHook : IChannelHook*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("ole32.dll")
	procCoRegisterChannelHook = ole32.NewProc("CoRegisterChannelHook")
)

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