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

ReportFault

関数
発生した例外の障害をWERに報告する。
DLLfaultrep.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

EFaultRepRetVal ReportFault(
    EXCEPTION_POINTERS* pep,
    DWORD dwOpt
);

パラメーター

名前方向
pepEXCEPTION_POINTERS*in
dwOptDWORDin

戻り値の型: EFaultRepRetVal

各言語での呼び出し定義

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

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

ReportFault = ctypes.windll.faultrep.ReportFault
ReportFault.restype = ctypes.c_int
ReportFault.argtypes = [
    ctypes.c_void_p,  # pep : EXCEPTION_POINTERS*
    wintypes.DWORD,  # dwOpt : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	faultrep = windows.NewLazySystemDLL("faultrep.dll")
	procReportFault = faultrep.NewProc("ReportFault")
)

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