Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug › UnhandledExceptionFilter

UnhandledExceptionFilter

関数
未処理例外に対する既定のシステムフィルタを呼び出す。
DLLKERNEL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

INT UnhandledExceptionFilter(
    EXCEPTION_POINTERS* ExceptionInfo
);

パラメーター

名前方向
ExceptionInfoEXCEPTION_POINTERS*in

戻り値の型: INT

各言語での呼び出し定義

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

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

UnhandledExceptionFilter = ctypes.windll.kernel32.UnhandledExceptionFilter
UnhandledExceptionFilter.restype = ctypes.c_int
UnhandledExceptionFilter.argtypes = [
    ctypes.c_void_p,  # ExceptionInfo : EXCEPTION_POINTERS*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procUnhandledExceptionFilter = kernel32.NewProc("UnhandledExceptionFilter")
)

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