ホーム › System.ErrorReporting › WerReportSetParameter
WerReportSetParameter
関数WERレポートのパラメータ名と値を設定する。
シグネチャ
// wer.dll
#include <windows.h>
HRESULT WerReportSetParameter(
HREPORT hReportHandle,
DWORD dwparamID,
LPCWSTR pwzName, // optional
LPCWSTR pwzValue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hReportHandle | HREPORT | in | 対象レポートのHREPORTハンドル。 |
| dwparamID | DWORD | in | 設定するパラメータのインデックス(0〜9)。 |
| pwzName | LPCWSTR | inoptional | パラメータ名を指すワイド文字列。NULL可。 |
| pwzValue | LPCWSTR | in | パラメータ値を指すワイド文字列。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// wer.dll
#include <windows.h>
HRESULT WerReportSetParameter(
HREPORT hReportHandle,
DWORD dwparamID,
LPCWSTR pwzName, // optional
LPCWSTR pwzValue
);[DllImport("wer.dll", ExactSpelling = true)]
static extern int WerReportSetParameter(
IntPtr hReportHandle, // HREPORT
uint dwparamID, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pwzName, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string pwzValue // LPCWSTR
);<DllImport("wer.dll", ExactSpelling:=True)>
Public Shared Function WerReportSetParameter(
hReportHandle As IntPtr, ' HREPORT
dwparamID As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pwzName As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> pwzValue As String ' LPCWSTR
) As Integer
End Function' hReportHandle : HREPORT
' dwparamID : DWORD
' pwzName : LPCWSTR optional
' pwzValue : LPCWSTR
Declare PtrSafe Function WerReportSetParameter Lib "wer" ( _
ByVal hReportHandle As LongPtr, _
ByVal dwparamID As Long, _
ByVal pwzName As LongPtr, _
ByVal pwzValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WerReportSetParameter = ctypes.windll.wer.WerReportSetParameter
WerReportSetParameter.restype = ctypes.c_int
WerReportSetParameter.argtypes = [
wintypes.HANDLE, # hReportHandle : HREPORT
wintypes.DWORD, # dwparamID : DWORD
wintypes.LPCWSTR, # pwzName : LPCWSTR optional
wintypes.LPCWSTR, # pwzValue : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wer.dll')
WerReportSetParameter = Fiddle::Function.new(
lib['WerReportSetParameter'],
[
Fiddle::TYPE_VOIDP, # hReportHandle : HREPORT
-Fiddle::TYPE_INT, # dwparamID : DWORD
Fiddle::TYPE_VOIDP, # pwzName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pwzValue : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "wer")]
extern "system" {
fn WerReportSetParameter(
hReportHandle: *mut core::ffi::c_void, // HREPORT
dwparamID: u32, // DWORD
pwzName: *const u16, // LPCWSTR optional
pwzValue: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wer.dll")]
public static extern int WerReportSetParameter(IntPtr hReportHandle, uint dwparamID, [MarshalAs(UnmanagedType.LPWStr)] string pwzName, [MarshalAs(UnmanagedType.LPWStr)] string pwzValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wer_WerReportSetParameter' -Namespace Win32 -PassThru
# $api::WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue)#uselib "wer.dll"
#func global WerReportSetParameter "WerReportSetParameter" sptr, sptr, sptr, sptr
; WerReportSetParameter hReportHandle, dwparamID, pwzName, pwzValue ; 戻り値は stat
; hReportHandle : HREPORT -> "sptr"
; dwparamID : DWORD -> "sptr"
; pwzName : LPCWSTR optional -> "sptr"
; pwzValue : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "wer.dll"
#cfunc global WerReportSetParameter "WerReportSetParameter" sptr, int, wstr, wstr
; res = WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue)
; hReportHandle : HREPORT -> "sptr"
; dwparamID : DWORD -> "int"
; pwzName : LPCWSTR optional -> "wstr"
; pwzValue : LPCWSTR -> "wstr"; HRESULT WerReportSetParameter(HREPORT hReportHandle, DWORD dwparamID, LPCWSTR pwzName, LPCWSTR pwzValue)
#uselib "wer.dll"
#cfunc global WerReportSetParameter "WerReportSetParameter" intptr, int, wstr, wstr
; res = WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue)
; hReportHandle : HREPORT -> "intptr"
; dwparamID : DWORD -> "int"
; pwzName : LPCWSTR optional -> "wstr"
; pwzValue : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wer = windows.NewLazySystemDLL("wer.dll")
procWerReportSetParameter = wer.NewProc("WerReportSetParameter")
)
// hReportHandle (HREPORT), dwparamID (DWORD), pwzName (LPCWSTR optional), pwzValue (LPCWSTR)
r1, _, err := procWerReportSetParameter.Call(
uintptr(hReportHandle),
uintptr(dwparamID),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzValue))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WerReportSetParameter(
hReportHandle: THandle; // HREPORT
dwparamID: DWORD; // DWORD
pwzName: PWideChar; // LPCWSTR optional
pwzValue: PWideChar // LPCWSTR
): Integer; stdcall;
external 'wer.dll' name 'WerReportSetParameter';result := DllCall("wer\WerReportSetParameter"
, "Ptr", hReportHandle ; HREPORT
, "UInt", dwparamID ; DWORD
, "WStr", pwzName ; LPCWSTR optional
, "WStr", pwzValue ; LPCWSTR
, "Int") ; return: HRESULT●WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue) = DLL("wer.dll", "int WerReportSetParameter(void*, dword, char*, char*)")
# 呼び出し: WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue)
# hReportHandle : HREPORT -> "void*"
# dwparamID : DWORD -> "dword"
# pwzName : LPCWSTR optional -> "char*"
# pwzValue : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wer" fn WerReportSetParameter(
hReportHandle: ?*anyopaque, // HREPORT
dwparamID: u32, // DWORD
pwzName: [*c]const u16, // LPCWSTR optional
pwzValue: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc WerReportSetParameter(
hReportHandle: pointer, # HREPORT
dwparamID: uint32, # DWORD
pwzName: WideCString, # LPCWSTR optional
pwzValue: WideCString # LPCWSTR
): int32 {.importc: "WerReportSetParameter", stdcall, dynlib: "wer.dll".}pragma(lib, "wer");
extern(Windows)
int WerReportSetParameter(
void* hReportHandle, // HREPORT
uint dwparamID, // DWORD
const(wchar)* pwzName, // LPCWSTR optional
const(wchar)* pwzValue // LPCWSTR
);ccall((:WerReportSetParameter, "wer.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Cwstring, Cwstring),
hReportHandle, dwparamID, pwzName, pwzValue)
# hReportHandle : HREPORT -> Ptr{Cvoid}
# dwparamID : DWORD -> UInt32
# pwzName : LPCWSTR optional -> Cwstring
# pwzValue : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WerReportSetParameter(
void* hReportHandle,
uint32_t dwparamID,
const uint16_t* pwzName,
const uint16_t* pwzValue);
]]
local wer = ffi.load("wer")
-- wer.WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue)
-- hReportHandle : HREPORT
-- dwparamID : DWORD
-- pwzName : LPCWSTR optional
-- pwzValue : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wer.dll');
const WerReportSetParameter = lib.func('__stdcall', 'WerReportSetParameter', 'int32_t', ['void *', 'uint32_t', 'str16', 'str16']);
// WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue)
// hReportHandle : HREPORT -> 'void *'
// dwparamID : DWORD -> 'uint32_t'
// pwzName : LPCWSTR optional -> 'str16'
// pwzValue : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wer.dll", {
WerReportSetParameter: { parameters: ["pointer", "u32", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue)
// hReportHandle : HREPORT -> "pointer"
// dwparamID : DWORD -> "u32"
// pwzName : LPCWSTR optional -> "buffer"
// pwzValue : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WerReportSetParameter(
void* hReportHandle,
uint32_t dwparamID,
const uint16_t* pwzName,
const uint16_t* pwzValue);
C, "wer.dll");
// $ffi->WerReportSetParameter(hReportHandle, dwparamID, pwzName, pwzValue);
// hReportHandle : HREPORT
// dwparamID : DWORD
// pwzName : LPCWSTR optional
// 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 WerReportSetParameter(
Pointer hReportHandle, // HREPORT
int dwparamID, // DWORD
WString pwzName, // LPCWSTR optional
WString pwzValue // LPCWSTR
);
}@[Link("wer")]
lib Libwer
fun WerReportSetParameter = WerReportSetParameter(
hReportHandle : Void*, # HREPORT
dwparamID : UInt32, # DWORD
pwzName : UInt16*, # LPCWSTR optional
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 WerReportSetParameterNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Utf16>);
typedef WerReportSetParameterDart = int Function(Pointer<Void>, int, Pointer<Utf16>, Pointer<Utf16>);
final WerReportSetParameter = DynamicLibrary.open('wer.dll')
.lookupFunction<WerReportSetParameterNative, WerReportSetParameterDart>('WerReportSetParameter');
// hReportHandle : HREPORT -> Pointer<Void>
// dwparamID : DWORD -> Uint32
// pwzName : LPCWSTR optional -> Pointer<Utf16>
// pwzValue : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WerReportSetParameter(
hReportHandle: THandle; // HREPORT
dwparamID: DWORD; // DWORD
pwzName: PWideChar; // LPCWSTR optional
pwzValue: PWideChar // LPCWSTR
): Integer; stdcall;
external 'wer.dll' name 'WerReportSetParameter';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WerReportSetParameter"
c_WerReportSetParameter :: Ptr () -> Word32 -> CWString -> CWString -> IO Int32
-- hReportHandle : HREPORT -> Ptr ()
-- dwparamID : DWORD -> Word32
-- pwzName : LPCWSTR optional -> CWString
-- pwzValue : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let werreportsetparameter =
foreign "WerReportSetParameter"
((ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hReportHandle : HREPORT -> (ptr void) *)
(* dwparamID : DWORD -> uint32_t *)
(* pwzName : LPCWSTR optional -> (ptr uint16_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 ("WerReportSetParameter" wer-report-set-parameter :convention :stdcall) :int32
(h-report-handle :pointer) ; HREPORT
(dwparam-id :uint32) ; DWORD
(pwz-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(pwz-value (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WerReportSetParameter = Win32::API::More->new('wer',
'int WerReportSetParameter(HANDLE hReportHandle, DWORD dwparamID, LPCWSTR pwzName, LPCWSTR pwzValue)');
# my $ret = $WerReportSetParameter->Call($hReportHandle, $dwparamID, $pwzName, $pwzValue);
# hReportHandle : HREPORT -> HANDLE
# dwparamID : DWORD -> DWORD
# pwzName : LPCWSTR optional -> LPCWSTR
# pwzValue : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。