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

RegisterBadMemoryNotification

関数
不良メモリ検出時のコールバック通知を登録する。
DLLKERNEL32.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

void* RegisterBadMemoryNotification(
    PBAD_MEMORY_CALLBACK_ROUTINE Callback
);

パラメーター

名前方向
CallbackPBAD_MEMORY_CALLBACK_ROUTINEin

戻り値の型: void*

各言語での呼び出し定義

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

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

RegisterBadMemoryNotification = ctypes.windll.kernel32.RegisterBadMemoryNotification
RegisterBadMemoryNotification.restype = ctypes.c_void_p
RegisterBadMemoryNotification.argtypes = [
    ctypes.c_void_p,  # Callback : PBAD_MEMORY_CALLBACK_ROUTINE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procRegisterBadMemoryNotification = kernel32.NewProc("RegisterBadMemoryNotification")
)

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