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

WerReportSetUIOption

関数
WERレポートのUI表示オプションを設定する。
DLLwer.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT WerReportSetUIOption(
    HREPORT hReportHandle,
    WER_REPORT_UI repUITypeID,
    LPCWSTR pwzValue
);

パラメーター

名前方向説明
hReportHandleHREPORTin対象レポートのHREPORTハンドル。
repUITypeIDWER_REPORT_UIin変更するUI要素を指定するWER_REPORT_UI列挙値。
pwzValueLPCWSTRin設定するUI文字列値を指すワイド文字列。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

WerReportSetUIOption = ctypes.windll.wer.WerReportSetUIOption
WerReportSetUIOption.restype = ctypes.c_int
WerReportSetUIOption.argtypes = [
    wintypes.HANDLE,  # hReportHandle : HREPORT
    ctypes.c_int,  # repUITypeID : WER_REPORT_UI
    wintypes.LPCWSTR,  # pwzValue : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wer.dll')
WerReportSetUIOption = Fiddle::Function.new(
  lib['WerReportSetUIOption'],
  [
    Fiddle::TYPE_VOIDP,  # hReportHandle : HREPORT
    Fiddle::TYPE_INT,  # repUITypeID : WER_REPORT_UI
    Fiddle::TYPE_VOIDP,  # pwzValue : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "wer")]
extern "system" {
    fn WerReportSetUIOption(
        hReportHandle: *mut core::ffi::c_void,  // HREPORT
        repUITypeID: i32,  // WER_REPORT_UI
        pwzValue: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wer.dll")]
public static extern int WerReportSetUIOption(IntPtr hReportHandle, int repUITypeID, [MarshalAs(UnmanagedType.LPWStr)] string pwzValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wer_WerReportSetUIOption' -Namespace Win32 -PassThru
# $api::WerReportSetUIOption(hReportHandle, repUITypeID, pwzValue)
#uselib "wer.dll"
#func global WerReportSetUIOption "WerReportSetUIOption" sptr, sptr, sptr
; WerReportSetUIOption hReportHandle, repUITypeID, pwzValue   ; 戻り値は stat
; hReportHandle : HREPORT -> "sptr"
; repUITypeID : WER_REPORT_UI -> "sptr"
; pwzValue : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "wer.dll"
#cfunc global WerReportSetUIOption "WerReportSetUIOption" sptr, int, wstr
; res = WerReportSetUIOption(hReportHandle, repUITypeID, pwzValue)
; hReportHandle : HREPORT -> "sptr"
; repUITypeID : WER_REPORT_UI -> "int"
; pwzValue : LPCWSTR -> "wstr"
; HRESULT WerReportSetUIOption(HREPORT hReportHandle, WER_REPORT_UI repUITypeID, LPCWSTR pwzValue)
#uselib "wer.dll"
#cfunc global WerReportSetUIOption "WerReportSetUIOption" intptr, int, wstr
; res = WerReportSetUIOption(hReportHandle, repUITypeID, pwzValue)
; hReportHandle : HREPORT -> "intptr"
; repUITypeID : WER_REPORT_UI -> "int"
; pwzValue : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wer = windows.NewLazySystemDLL("wer.dll")
	procWerReportSetUIOption = wer.NewProc("WerReportSetUIOption")
)

// hReportHandle (HREPORT), repUITypeID (WER_REPORT_UI), pwzValue (LPCWSTR)
r1, _, err := procWerReportSetUIOption.Call(
	uintptr(hReportHandle),
	uintptr(repUITypeID),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzValue))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WerReportSetUIOption(
  hReportHandle: THandle;   // HREPORT
  repUITypeID: Integer;   // WER_REPORT_UI
  pwzValue: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'wer.dll' name 'WerReportSetUIOption';
result := DllCall("wer\WerReportSetUIOption"
    , "Ptr", hReportHandle   ; HREPORT
    , "Int", repUITypeID   ; WER_REPORT_UI
    , "WStr", pwzValue   ; LPCWSTR
    , "Int")   ; return: HRESULT
●WerReportSetUIOption(hReportHandle, repUITypeID, pwzValue) = DLL("wer.dll", "int WerReportSetUIOption(void*, int, char*)")
# 呼び出し: WerReportSetUIOption(hReportHandle, repUITypeID, pwzValue)
# hReportHandle : HREPORT -> "void*"
# repUITypeID : WER_REPORT_UI -> "int"
# pwzValue : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef WerReportSetUIOptionNative = Int32 Function(Pointer<Void>, Int32, Pointer<Utf16>);
typedef WerReportSetUIOptionDart = int Function(Pointer<Void>, int, Pointer<Utf16>);
final WerReportSetUIOption = DynamicLibrary.open('wer.dll')
    .lookupFunction<WerReportSetUIOptionNative, WerReportSetUIOptionDart>('WerReportSetUIOption');
// hReportHandle : HREPORT -> Pointer<Void>
// repUITypeID : WER_REPORT_UI -> Int32
// pwzValue : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WerReportSetUIOption(
  hReportHandle: THandle;   // HREPORT
  repUITypeID: Integer;   // WER_REPORT_UI
  pwzValue: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'wer.dll' name 'WerReportSetUIOption';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WerReportSetUIOption"
  c_WerReportSetUIOption :: Ptr () -> Int32 -> CWString -> IO Int32
-- hReportHandle : HREPORT -> Ptr ()
-- repUITypeID : WER_REPORT_UI -> Int32
-- pwzValue : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let werreportsetuioption =
  foreign "WerReportSetUIOption"
    ((ptr void) @-> int32_t @-> (ptr uint16_t) @-> returning int32_t)
(* hReportHandle : HREPORT -> (ptr void) *)
(* repUITypeID : WER_REPORT_UI -> int32_t *)
(* pwzValue : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wer (t "wer.dll"))
(cffi:use-foreign-library wer)

(cffi:defcfun ("WerReportSetUIOption" wer-report-set-uioption :convention :stdcall) :int32
  (h-report-handle :pointer)   ; HREPORT
  (rep-uitype-id :int32)   ; WER_REPORT_UI
  (pwz-value (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WerReportSetUIOption = Win32::API::More->new('wer',
    'int WerReportSetUIOption(HANDLE hReportHandle, int repUITypeID, LPCWSTR pwzValue)');
# my $ret = $WerReportSetUIOption->Call($hReportHandle, $repUITypeID, $pwzValue);
# hReportHandle : HREPORT -> HANDLE
# repUITypeID : WER_REPORT_UI -> int
# pwzValue : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型