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

WerReportCreate

関数
WERのエラーレポートを新規に作成する。
DLLwer.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT WerReportCreate(
    LPCWSTR pwzEventType,
    WER_REPORT_TYPE repType,
    WER_REPORT_INFORMATION* pReportInformation,   // optional
    HREPORT* phReportHandle
);

パラメーター

名前方向
pwzEventTypeLPCWSTRin
repTypeWER_REPORT_TYPEin
pReportInformationWER_REPORT_INFORMATION*inoptional
phReportHandleHREPORT*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WerReportCreate(
    LPCWSTR pwzEventType,
    WER_REPORT_TYPE repType,
    WER_REPORT_INFORMATION* pReportInformation,   // optional
    HREPORT* phReportHandle
);
[DllImport("wer.dll", ExactSpelling = true)]
static extern int WerReportCreate(
    [MarshalAs(UnmanagedType.LPWStr)] string pwzEventType,   // LPCWSTR
    int repType,   // WER_REPORT_TYPE
    IntPtr pReportInformation,   // WER_REPORT_INFORMATION* optional
    IntPtr phReportHandle   // HREPORT* out
);
<DllImport("wer.dll", ExactSpelling:=True)>
Public Shared Function WerReportCreate(
    <MarshalAs(UnmanagedType.LPWStr)> pwzEventType As String,   ' LPCWSTR
    repType As Integer,   ' WER_REPORT_TYPE
    pReportInformation As IntPtr,   ' WER_REPORT_INFORMATION* optional
    phReportHandle As IntPtr   ' HREPORT* out
) As Integer
End Function
' pwzEventType : LPCWSTR
' repType : WER_REPORT_TYPE
' pReportInformation : WER_REPORT_INFORMATION* optional
' phReportHandle : HREPORT* out
Declare PtrSafe Function WerReportCreate Lib "wer" ( _
    ByVal pwzEventType As LongPtr, _
    ByVal repType As Long, _
    ByVal pReportInformation As LongPtr, _
    ByVal phReportHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WerReportCreate = ctypes.windll.wer.WerReportCreate
WerReportCreate.restype = ctypes.c_int
WerReportCreate.argtypes = [
    wintypes.LPCWSTR,  # pwzEventType : LPCWSTR
    ctypes.c_int,  # repType : WER_REPORT_TYPE
    ctypes.c_void_p,  # pReportInformation : WER_REPORT_INFORMATION* optional
    ctypes.c_void_p,  # phReportHandle : HREPORT* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wer = windows.NewLazySystemDLL("wer.dll")
	procWerReportCreate = wer.NewProc("WerReportCreate")
)

// pwzEventType (LPCWSTR), repType (WER_REPORT_TYPE), pReportInformation (WER_REPORT_INFORMATION* optional), phReportHandle (HREPORT* out)
r1, _, err := procWerReportCreate.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzEventType))),
	uintptr(repType),
	uintptr(pReportInformation),
	uintptr(phReportHandle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WerReportCreate(
  pwzEventType: PWideChar;   // LPCWSTR
  repType: Integer;   // WER_REPORT_TYPE
  pReportInformation: Pointer;   // WER_REPORT_INFORMATION* optional
  phReportHandle: Pointer   // HREPORT* out
): Integer; stdcall;
  external 'wer.dll' name 'WerReportCreate';
result := DllCall("wer\WerReportCreate"
    , "WStr", pwzEventType   ; LPCWSTR
    , "Int", repType   ; WER_REPORT_TYPE
    , "Ptr", pReportInformation   ; WER_REPORT_INFORMATION* optional
    , "Ptr", phReportHandle   ; HREPORT* out
    , "Int")   ; return: HRESULT
●WerReportCreate(pwzEventType, repType, pReportInformation, phReportHandle) = DLL("wer.dll", "int WerReportCreate(char*, int, void*, void*)")
# 呼び出し: WerReportCreate(pwzEventType, repType, pReportInformation, phReportHandle)
# pwzEventType : LPCWSTR -> "char*"
# repType : WER_REPORT_TYPE -> "int"
# pReportInformation : WER_REPORT_INFORMATION* optional -> "void*"
# phReportHandle : HREPORT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。