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

CoRegisterMallocSpy

関数
COMメモリ割り当てを監視するIMallocSpyを登録する。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT CoRegisterMallocSpy(
    IMallocSpy* pMallocSpy
);

パラメーター

名前方向
pMallocSpyIMallocSpy*in

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

CoRegisterMallocSpy = ctypes.windll.ole32.CoRegisterMallocSpy
CoRegisterMallocSpy.restype = ctypes.c_int
CoRegisterMallocSpy.argtypes = [
    ctypes.c_void_p,  # pMallocSpy : IMallocSpy*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OLE32.dll')
CoRegisterMallocSpy = Fiddle::Function.new(
  lib['CoRegisterMallocSpy'],
  [
    Fiddle::TYPE_VOIDP,  # pMallocSpy : IMallocSpy*
  ],
  Fiddle::TYPE_INT)
#[link(name = "ole32")]
extern "system" {
    fn CoRegisterMallocSpy(
        pMallocSpy: *mut core::ffi::c_void  // IMallocSpy*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OLE32.dll")]
public static extern int CoRegisterMallocSpy(IntPtr pMallocSpy);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_CoRegisterMallocSpy' -Namespace Win32 -PassThru
# $api::CoRegisterMallocSpy(pMallocSpy)
#uselib "OLE32.dll"
#func global CoRegisterMallocSpy "CoRegisterMallocSpy" sptr
; CoRegisterMallocSpy pMallocSpy   ; 戻り値は stat
; pMallocSpy : IMallocSpy* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "OLE32.dll"
#cfunc global CoRegisterMallocSpy "CoRegisterMallocSpy" sptr
; res = CoRegisterMallocSpy(pMallocSpy)
; pMallocSpy : IMallocSpy* -> "sptr"
; HRESULT CoRegisterMallocSpy(IMallocSpy* pMallocSpy)
#uselib "OLE32.dll"
#cfunc global CoRegisterMallocSpy "CoRegisterMallocSpy" intptr
; res = CoRegisterMallocSpy(pMallocSpy)
; pMallocSpy : IMallocSpy* -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procCoRegisterMallocSpy = ole32.NewProc("CoRegisterMallocSpy")
)

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