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

WerReportAddFile

関数
WERレポートに添付ファイルを追加する。
DLLwer.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT WerReportAddFile(
    HREPORT hReportHandle,
    LPCWSTR pwzPath,
    WER_FILE_TYPE repFileType,
    WER_FILE dwFileFlags
);

パラメーター

名前方向
hReportHandleHREPORTin
pwzPathLPCWSTRin
repFileTypeWER_FILE_TYPEin
dwFileFlagsWER_FILEin

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

WerReportAddFile = ctypes.windll.wer.WerReportAddFile
WerReportAddFile.restype = ctypes.c_int
WerReportAddFile.argtypes = [
    wintypes.HANDLE,  # hReportHandle : HREPORT
    wintypes.LPCWSTR,  # pwzPath : LPCWSTR
    ctypes.c_int,  # repFileType : WER_FILE_TYPE
    wintypes.DWORD,  # dwFileFlags : WER_FILE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wer = windows.NewLazySystemDLL("wer.dll")
	procWerReportAddFile = wer.NewProc("WerReportAddFile")
)

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