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
);

パラメーター

名前方向説明
pwzEventTypeLPCWSTRinWERイベントの種別名を指すワイド文字列。
repTypeWER_REPORT_TYPEin作成するレポートの種類を指定するWER_REPORT_TYPE列挙値。
pReportInformationWER_REPORT_INFORMATION*inoptionalレポートの付随情報を格納したWER_REPORT_INFORMATION構造体へのポインタ。NULL可。
phReportHandleHREPORT*out作成されたレポートのHREPORTハンドルを受け取るポインタ。

戻り値の型: 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)。
const std = @import("std");

extern "wer" fn WerReportCreate(
    pwzEventType: [*c]const u16, // LPCWSTR
    repType: i32, // WER_REPORT_TYPE
    pReportInformation: [*c]WER_REPORT_INFORMATION, // WER_REPORT_INFORMATION* optional
    phReportHandle: ?*anyopaque // HREPORT* out
) callconv(std.os.windows.WINAPI) i32;
proc WerReportCreate(
    pwzEventType: WideCString,  # LPCWSTR
    repType: int32,  # WER_REPORT_TYPE
    pReportInformation: ptr WER_REPORT_INFORMATION,  # WER_REPORT_INFORMATION* optional
    phReportHandle: pointer  # HREPORT* out
): int32 {.importc: "WerReportCreate", stdcall, dynlib: "wer.dll".}
pragma(lib, "wer");
extern(Windows)
int WerReportCreate(
    const(wchar)* pwzEventType,   // LPCWSTR
    int repType,   // WER_REPORT_TYPE
    WER_REPORT_INFORMATION* pReportInformation,   // WER_REPORT_INFORMATION* optional
    void* phReportHandle   // HREPORT* out
);
ccall((:WerReportCreate, "wer.dll"), stdcall, Int32,
      (Cwstring, Int32, Ptr{WER_REPORT_INFORMATION}, Ptr{Cvoid}),
      pwzEventType, repType, pReportInformation, phReportHandle)
# pwzEventType : LPCWSTR -> Cwstring
# repType : WER_REPORT_TYPE -> Int32
# pReportInformation : WER_REPORT_INFORMATION* optional -> Ptr{WER_REPORT_INFORMATION}
# phReportHandle : HREPORT* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WerReportCreate(
    const uint16_t* pwzEventType,
    int32_t repType,
    void* pReportInformation,
    void* phReportHandle);
]]
local wer = ffi.load("wer")
-- wer.WerReportCreate(pwzEventType, repType, pReportInformation, phReportHandle)
-- pwzEventType : LPCWSTR
-- repType : WER_REPORT_TYPE
-- pReportInformation : WER_REPORT_INFORMATION* optional
-- phReportHandle : HREPORT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wer.dll');
const WerReportCreate = lib.func('__stdcall', 'WerReportCreate', 'int32_t', ['str16', 'int32_t', 'void *', 'void *']);
// WerReportCreate(pwzEventType, repType, pReportInformation, phReportHandle)
// pwzEventType : LPCWSTR -> 'str16'
// repType : WER_REPORT_TYPE -> 'int32_t'
// pReportInformation : WER_REPORT_INFORMATION* optional -> 'void *'
// phReportHandle : HREPORT* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wer.dll", {
  WerReportCreate: { parameters: ["buffer", "i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WerReportCreate(pwzEventType, repType, pReportInformation, phReportHandle)
// pwzEventType : LPCWSTR -> "buffer"
// repType : WER_REPORT_TYPE -> "i32"
// pReportInformation : WER_REPORT_INFORMATION* optional -> "pointer"
// phReportHandle : HREPORT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WerReportCreate(
    const uint16_t* pwzEventType,
    int32_t repType,
    void* pReportInformation,
    void* phReportHandle);
C, "wer.dll");
// $ffi->WerReportCreate(pwzEventType, repType, pReportInformation, phReportHandle);
// pwzEventType : LPCWSTR
// repType : WER_REPORT_TYPE
// pReportInformation : WER_REPORT_INFORMATION* optional
// phReportHandle : HREPORT* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Wer extends StdCallLibrary {
    Wer INSTANCE = Native.load("wer", Wer.class);
    int WerReportCreate(
        WString pwzEventType,   // LPCWSTR
        int repType,   // WER_REPORT_TYPE
        Pointer pReportInformation,   // WER_REPORT_INFORMATION* optional
        Pointer phReportHandle   // HREPORT* out
    );
}
@[Link("wer")]
lib Libwer
  fun WerReportCreate = WerReportCreate(
    pwzEventType : UInt16*,   # LPCWSTR
    repType : Int32,   # WER_REPORT_TYPE
    pReportInformation : WER_REPORT_INFORMATION*,   # WER_REPORT_INFORMATION* optional
    phReportHandle : Void*   # HREPORT* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WerReportCreateNative = Int32 Function(Pointer<Utf16>, Int32, Pointer<Void>, Pointer<Void>);
typedef WerReportCreateDart = int Function(Pointer<Utf16>, int, Pointer<Void>, Pointer<Void>);
final WerReportCreate = DynamicLibrary.open('wer.dll')
    .lookupFunction<WerReportCreateNative, WerReportCreateDart>('WerReportCreate');
// pwzEventType : LPCWSTR -> Pointer<Utf16>
// repType : WER_REPORT_TYPE -> Int32
// pReportInformation : WER_REPORT_INFORMATION* optional -> Pointer<Void>
// phReportHandle : HREPORT* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WerReportCreate"
  c_WerReportCreate :: CWString -> Int32 -> Ptr () -> Ptr () -> IO Int32
-- pwzEventType : LPCWSTR -> CWString
-- repType : WER_REPORT_TYPE -> Int32
-- pReportInformation : WER_REPORT_INFORMATION* optional -> Ptr ()
-- phReportHandle : HREPORT* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let werreportcreate =
  foreign "WerReportCreate"
    ((ptr uint16_t) @-> int32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pwzEventType : LPCWSTR -> (ptr uint16_t) *)
(* repType : WER_REPORT_TYPE -> int32_t *)
(* pReportInformation : WER_REPORT_INFORMATION* optional -> (ptr void) *)
(* phReportHandle : HREPORT* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wer (t "wer.dll"))
(cffi:use-foreign-library wer)

(cffi:defcfun ("WerReportCreate" wer-report-create :convention :stdcall) :int32
  (pwz-event-type (:string :encoding :utf-16le))   ; LPCWSTR
  (rep-type :int32)   ; WER_REPORT_TYPE
  (p-report-information :pointer)   ; WER_REPORT_INFORMATION* optional
  (ph-report-handle :pointer))   ; HREPORT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WerReportCreate = Win32::API::More->new('wer',
    'int WerReportCreate(LPCWSTR pwzEventType, int repType, LPVOID pReportInformation, HANDLE phReportHandle)');
# my $ret = $WerReportCreate->Call($pwzEventType, $repType, $pReportInformation, $phReportHandle);
# pwzEventType : LPCWSTR -> LPCWSTR
# repType : WER_REPORT_TYPE -> int
# pReportInformation : WER_REPORT_INFORMATION* optional -> LPVOID
# phReportHandle : HREPORT* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型