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

WerReportSubmit

関数
作成したWERレポートをサーバーへ送信する。
DLLwer.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT WerReportSubmit(
    HREPORT hReportHandle,
    WER_CONSENT consent,
    WER_SUBMIT_FLAGS dwFlags,
    WER_SUBMIT_RESULT* pSubmitResult   // optional
);

パラメーター

名前方向説明
hReportHandleHREPORTin送信する対象レポートのHREPORTハンドル。
consentWER_CONSENTinユーザー同意状態を示すWER_CONSENT列挙値。
dwFlagsWER_SUBMIT_FLAGSin送信動作を制御するWER_SUBMIT_FLAGSビットフラグ。
pSubmitResultWER_SUBMIT_RESULT*outoptional送信結果を受け取るWER_SUBMIT_RESULTへのポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WerReportSubmit(
    HREPORT hReportHandle,
    WER_CONSENT consent,
    WER_SUBMIT_FLAGS dwFlags,
    WER_SUBMIT_RESULT* pSubmitResult   // optional
);
[DllImport("wer.dll", ExactSpelling = true)]
static extern int WerReportSubmit(
    IntPtr hReportHandle,   // HREPORT
    int consent,   // WER_CONSENT
    uint dwFlags,   // WER_SUBMIT_FLAGS
    IntPtr pSubmitResult   // WER_SUBMIT_RESULT* optional, out
);
<DllImport("wer.dll", ExactSpelling:=True)>
Public Shared Function WerReportSubmit(
    hReportHandle As IntPtr,   ' HREPORT
    consent As Integer,   ' WER_CONSENT
    dwFlags As UInteger,   ' WER_SUBMIT_FLAGS
    pSubmitResult As IntPtr   ' WER_SUBMIT_RESULT* optional, out
) As Integer
End Function
' hReportHandle : HREPORT
' consent : WER_CONSENT
' dwFlags : WER_SUBMIT_FLAGS
' pSubmitResult : WER_SUBMIT_RESULT* optional, out
Declare PtrSafe Function WerReportSubmit Lib "wer" ( _
    ByVal hReportHandle As LongPtr, _
    ByVal consent As Long, _
    ByVal dwFlags As Long, _
    ByVal pSubmitResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WerReportSubmit = ctypes.windll.wer.WerReportSubmit
WerReportSubmit.restype = ctypes.c_int
WerReportSubmit.argtypes = [
    wintypes.HANDLE,  # hReportHandle : HREPORT
    ctypes.c_int,  # consent : WER_CONSENT
    wintypes.DWORD,  # dwFlags : WER_SUBMIT_FLAGS
    ctypes.c_void_p,  # pSubmitResult : WER_SUBMIT_RESULT* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wer = windows.NewLazySystemDLL("wer.dll")
	procWerReportSubmit = wer.NewProc("WerReportSubmit")
)

// hReportHandle (HREPORT), consent (WER_CONSENT), dwFlags (WER_SUBMIT_FLAGS), pSubmitResult (WER_SUBMIT_RESULT* optional, out)
r1, _, err := procWerReportSubmit.Call(
	uintptr(hReportHandle),
	uintptr(consent),
	uintptr(dwFlags),
	uintptr(pSubmitResult),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WerReportSubmit(
  hReportHandle: THandle;   // HREPORT
  consent: Integer;   // WER_CONSENT
  dwFlags: DWORD;   // WER_SUBMIT_FLAGS
  pSubmitResult: Pointer   // WER_SUBMIT_RESULT* optional, out
): Integer; stdcall;
  external 'wer.dll' name 'WerReportSubmit';
result := DllCall("wer\WerReportSubmit"
    , "Ptr", hReportHandle   ; HREPORT
    , "Int", consent   ; WER_CONSENT
    , "UInt", dwFlags   ; WER_SUBMIT_FLAGS
    , "Ptr", pSubmitResult   ; WER_SUBMIT_RESULT* optional, out
    , "Int")   ; return: HRESULT
●WerReportSubmit(hReportHandle, consent, dwFlags, pSubmitResult) = DLL("wer.dll", "int WerReportSubmit(void*, int, dword, void*)")
# 呼び出し: WerReportSubmit(hReportHandle, consent, dwFlags, pSubmitResult)
# hReportHandle : HREPORT -> "void*"
# consent : WER_CONSENT -> "int"
# dwFlags : WER_SUBMIT_FLAGS -> "dword"
# pSubmitResult : WER_SUBMIT_RESULT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wer" fn WerReportSubmit(
    hReportHandle: ?*anyopaque, // HREPORT
    consent: i32, // WER_CONSENT
    dwFlags: u32, // WER_SUBMIT_FLAGS
    pSubmitResult: [*c]i32 // WER_SUBMIT_RESULT* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc WerReportSubmit(
    hReportHandle: pointer,  # HREPORT
    consent: int32,  # WER_CONSENT
    dwFlags: uint32,  # WER_SUBMIT_FLAGS
    pSubmitResult: ptr int32  # WER_SUBMIT_RESULT* optional, out
): int32 {.importc: "WerReportSubmit", stdcall, dynlib: "wer.dll".}
pragma(lib, "wer");
extern(Windows)
int WerReportSubmit(
    void* hReportHandle,   // HREPORT
    int consent,   // WER_CONSENT
    uint dwFlags,   // WER_SUBMIT_FLAGS
    int* pSubmitResult   // WER_SUBMIT_RESULT* optional, out
);
ccall((:WerReportSubmit, "wer.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32, UInt32, Ptr{Int32}),
      hReportHandle, consent, dwFlags, pSubmitResult)
# hReportHandle : HREPORT -> Ptr{Cvoid}
# consent : WER_CONSENT -> Int32
# dwFlags : WER_SUBMIT_FLAGS -> UInt32
# pSubmitResult : WER_SUBMIT_RESULT* optional, out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WerReportSubmit(
    void* hReportHandle,
    int32_t consent,
    uint32_t dwFlags,
    int32_t* pSubmitResult);
]]
local wer = ffi.load("wer")
-- wer.WerReportSubmit(hReportHandle, consent, dwFlags, pSubmitResult)
-- hReportHandle : HREPORT
-- consent : WER_CONSENT
-- dwFlags : WER_SUBMIT_FLAGS
-- pSubmitResult : WER_SUBMIT_RESULT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wer.dll');
const WerReportSubmit = lib.func('__stdcall', 'WerReportSubmit', 'int32_t', ['void *', 'int32_t', 'uint32_t', 'int32_t *']);
// WerReportSubmit(hReportHandle, consent, dwFlags, pSubmitResult)
// hReportHandle : HREPORT -> 'void *'
// consent : WER_CONSENT -> 'int32_t'
// dwFlags : WER_SUBMIT_FLAGS -> 'uint32_t'
// pSubmitResult : WER_SUBMIT_RESULT* optional, out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wer.dll", {
  WerReportSubmit: { parameters: ["pointer", "i32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.WerReportSubmit(hReportHandle, consent, dwFlags, pSubmitResult)
// hReportHandle : HREPORT -> "pointer"
// consent : WER_CONSENT -> "i32"
// dwFlags : WER_SUBMIT_FLAGS -> "u32"
// pSubmitResult : WER_SUBMIT_RESULT* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WerReportSubmit(
    void* hReportHandle,
    int32_t consent,
    uint32_t dwFlags,
    int32_t* pSubmitResult);
C, "wer.dll");
// $ffi->WerReportSubmit(hReportHandle, consent, dwFlags, pSubmitResult);
// hReportHandle : HREPORT
// consent : WER_CONSENT
// dwFlags : WER_SUBMIT_FLAGS
// pSubmitResult : WER_SUBMIT_RESULT* optional, 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 WerReportSubmit(
        Pointer hReportHandle,   // HREPORT
        int consent,   // WER_CONSENT
        int dwFlags,   // WER_SUBMIT_FLAGS
        IntByReference pSubmitResult   // WER_SUBMIT_RESULT* optional, out
    );
}
@[Link("wer")]
lib Libwer
  fun WerReportSubmit = WerReportSubmit(
    hReportHandle : Void*,   # HREPORT
    consent : Int32,   # WER_CONSENT
    dwFlags : UInt32,   # WER_SUBMIT_FLAGS
    pSubmitResult : Int32*   # WER_SUBMIT_RESULT* optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WerReportSubmitNative = Int32 Function(Pointer<Void>, Int32, Uint32, Pointer<Int32>);
typedef WerReportSubmitDart = int Function(Pointer<Void>, int, int, Pointer<Int32>);
final WerReportSubmit = DynamicLibrary.open('wer.dll')
    .lookupFunction<WerReportSubmitNative, WerReportSubmitDart>('WerReportSubmit');
// hReportHandle : HREPORT -> Pointer<Void>
// consent : WER_CONSENT -> Int32
// dwFlags : WER_SUBMIT_FLAGS -> Uint32
// pSubmitResult : WER_SUBMIT_RESULT* optional, out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WerReportSubmit(
  hReportHandle: THandle;   // HREPORT
  consent: Integer;   // WER_CONSENT
  dwFlags: DWORD;   // WER_SUBMIT_FLAGS
  pSubmitResult: Pointer   // WER_SUBMIT_RESULT* optional, out
): Integer; stdcall;
  external 'wer.dll' name 'WerReportSubmit';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WerReportSubmit"
  c_WerReportSubmit :: Ptr () -> Int32 -> Word32 -> Ptr Int32 -> IO Int32
-- hReportHandle : HREPORT -> Ptr ()
-- consent : WER_CONSENT -> Int32
-- dwFlags : WER_SUBMIT_FLAGS -> Word32
-- pSubmitResult : WER_SUBMIT_RESULT* optional, out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let werreportsubmit =
  foreign "WerReportSubmit"
    ((ptr void) @-> int32_t @-> uint32_t @-> (ptr int32_t) @-> returning int32_t)
(* hReportHandle : HREPORT -> (ptr void) *)
(* consent : WER_CONSENT -> int32_t *)
(* dwFlags : WER_SUBMIT_FLAGS -> uint32_t *)
(* pSubmitResult : WER_SUBMIT_RESULT* optional, out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wer (t "wer.dll"))
(cffi:use-foreign-library wer)

(cffi:defcfun ("WerReportSubmit" wer-report-submit :convention :stdcall) :int32
  (h-report-handle :pointer)   ; HREPORT
  (consent :int32)   ; WER_CONSENT
  (dw-flags :uint32)   ; WER_SUBMIT_FLAGS
  (p-submit-result :pointer))   ; WER_SUBMIT_RESULT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WerReportSubmit = Win32::API::More->new('wer',
    'int WerReportSubmit(HANDLE hReportHandle, int consent, DWORD dwFlags, LPVOID pSubmitResult)');
# my $ret = $WerReportSubmit->Call($hReportHandle, $consent, $dwFlags, $pSubmitResult);
# hReportHandle : HREPORT -> HANDLE
# consent : WER_CONSENT -> int
# dwFlags : WER_SUBMIT_FLAGS -> DWORD
# pSubmitResult : WER_SUBMIT_RESULT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型