ホーム › System.ErrorReporting › WerReportHang
WerReportHang
関数応答停止したアプリのハングをWERに報告する。
シグネチャ
// faultrep.dll
#include <windows.h>
HRESULT WerReportHang(
HWND hwndHungApp,
LPCWSTR pwzHungApplicationName // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwndHungApp | HWND | in | ハングしたアプリケーションのウィンドウハンドル。 |
| pwzHungApplicationName | LPCWSTR | inoptional | ハングしたアプリケーション名を指すワイド文字列。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// faultrep.dll
#include <windows.h>
HRESULT WerReportHang(
HWND hwndHungApp,
LPCWSTR pwzHungApplicationName // optional
);[DllImport("faultrep.dll", ExactSpelling = true)]
static extern int WerReportHang(
IntPtr hwndHungApp, // HWND
[MarshalAs(UnmanagedType.LPWStr)] string pwzHungApplicationName // LPCWSTR optional
);<DllImport("faultrep.dll", ExactSpelling:=True)>
Public Shared Function WerReportHang(
hwndHungApp As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPWStr)> pwzHungApplicationName As String ' LPCWSTR optional
) As Integer
End Function' hwndHungApp : HWND
' pwzHungApplicationName : LPCWSTR optional
Declare PtrSafe Function WerReportHang Lib "faultrep" ( _
ByVal hwndHungApp As LongPtr, _
ByVal pwzHungApplicationName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WerReportHang = ctypes.windll.faultrep.WerReportHang
WerReportHang.restype = ctypes.c_int
WerReportHang.argtypes = [
wintypes.HANDLE, # hwndHungApp : HWND
wintypes.LPCWSTR, # pwzHungApplicationName : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('faultrep.dll')
WerReportHang = Fiddle::Function.new(
lib['WerReportHang'],
[
Fiddle::TYPE_VOIDP, # hwndHungApp : HWND
Fiddle::TYPE_VOIDP, # pwzHungApplicationName : LPCWSTR optional
],
Fiddle::TYPE_INT)#[link(name = "faultrep")]
extern "system" {
fn WerReportHang(
hwndHungApp: *mut core::ffi::c_void, // HWND
pwzHungApplicationName: *const u16 // LPCWSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("faultrep.dll")]
public static extern int WerReportHang(IntPtr hwndHungApp, [MarshalAs(UnmanagedType.LPWStr)] string pwzHungApplicationName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'faultrep_WerReportHang' -Namespace Win32 -PassThru
# $api::WerReportHang(hwndHungApp, pwzHungApplicationName)#uselib "faultrep.dll"
#func global WerReportHang "WerReportHang" sptr, sptr
; WerReportHang hwndHungApp, pwzHungApplicationName ; 戻り値は stat
; hwndHungApp : HWND -> "sptr"
; pwzHungApplicationName : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "faultrep.dll"
#cfunc global WerReportHang "WerReportHang" sptr, wstr
; res = WerReportHang(hwndHungApp, pwzHungApplicationName)
; hwndHungApp : HWND -> "sptr"
; pwzHungApplicationName : LPCWSTR optional -> "wstr"; HRESULT WerReportHang(HWND hwndHungApp, LPCWSTR pwzHungApplicationName)
#uselib "faultrep.dll"
#cfunc global WerReportHang "WerReportHang" intptr, wstr
; res = WerReportHang(hwndHungApp, pwzHungApplicationName)
; hwndHungApp : HWND -> "intptr"
; pwzHungApplicationName : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
faultrep = windows.NewLazySystemDLL("faultrep.dll")
procWerReportHang = faultrep.NewProc("WerReportHang")
)
// hwndHungApp (HWND), pwzHungApplicationName (LPCWSTR optional)
r1, _, err := procWerReportHang.Call(
uintptr(hwndHungApp),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzHungApplicationName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WerReportHang(
hwndHungApp: THandle; // HWND
pwzHungApplicationName: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'faultrep.dll' name 'WerReportHang';result := DllCall("faultrep\WerReportHang"
, "Ptr", hwndHungApp ; HWND
, "WStr", pwzHungApplicationName ; LPCWSTR optional
, "Int") ; return: HRESULT●WerReportHang(hwndHungApp, pwzHungApplicationName) = DLL("faultrep.dll", "int WerReportHang(void*, char*)")
# 呼び出し: WerReportHang(hwndHungApp, pwzHungApplicationName)
# hwndHungApp : HWND -> "void*"
# pwzHungApplicationName : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "faultrep" fn WerReportHang(
hwndHungApp: ?*anyopaque, // HWND
pwzHungApplicationName: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) i32;proc WerReportHang(
hwndHungApp: pointer, # HWND
pwzHungApplicationName: WideCString # LPCWSTR optional
): int32 {.importc: "WerReportHang", stdcall, dynlib: "faultrep.dll".}pragma(lib, "faultrep");
extern(Windows)
int WerReportHang(
void* hwndHungApp, // HWND
const(wchar)* pwzHungApplicationName // LPCWSTR optional
);ccall((:WerReportHang, "faultrep.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring),
hwndHungApp, pwzHungApplicationName)
# hwndHungApp : HWND -> Ptr{Cvoid}
# pwzHungApplicationName : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WerReportHang(
void* hwndHungApp,
const uint16_t* pwzHungApplicationName);
]]
local faultrep = ffi.load("faultrep")
-- faultrep.WerReportHang(hwndHungApp, pwzHungApplicationName)
-- hwndHungApp : HWND
-- pwzHungApplicationName : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('faultrep.dll');
const WerReportHang = lib.func('__stdcall', 'WerReportHang', 'int32_t', ['void *', 'str16']);
// WerReportHang(hwndHungApp, pwzHungApplicationName)
// hwndHungApp : HWND -> 'void *'
// pwzHungApplicationName : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("faultrep.dll", {
WerReportHang: { parameters: ["pointer", "buffer"], result: "i32" },
});
// lib.symbols.WerReportHang(hwndHungApp, pwzHungApplicationName)
// hwndHungApp : HWND -> "pointer"
// pwzHungApplicationName : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WerReportHang(
void* hwndHungApp,
const uint16_t* pwzHungApplicationName);
C, "faultrep.dll");
// $ffi->WerReportHang(hwndHungApp, pwzHungApplicationName);
// hwndHungApp : HWND
// pwzHungApplicationName : LPCWSTR optional
// 構造体/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 Faultrep extends StdCallLibrary {
Faultrep INSTANCE = Native.load("faultrep", Faultrep.class);
int WerReportHang(
Pointer hwndHungApp, // HWND
WString pwzHungApplicationName // LPCWSTR optional
);
}@[Link("faultrep")]
lib Libfaultrep
fun WerReportHang = WerReportHang(
hwndHungApp : Void*, # HWND
pwzHungApplicationName : UInt16* # LPCWSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WerReportHangNative = Int32 Function(Pointer<Void>, Pointer<Utf16>);
typedef WerReportHangDart = int Function(Pointer<Void>, Pointer<Utf16>);
final WerReportHang = DynamicLibrary.open('faultrep.dll')
.lookupFunction<WerReportHangNative, WerReportHangDart>('WerReportHang');
// hwndHungApp : HWND -> Pointer<Void>
// pwzHungApplicationName : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WerReportHang(
hwndHungApp: THandle; // HWND
pwzHungApplicationName: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'faultrep.dll' name 'WerReportHang';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WerReportHang"
c_WerReportHang :: Ptr () -> CWString -> IO Int32
-- hwndHungApp : HWND -> Ptr ()
-- pwzHungApplicationName : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let werreporthang =
foreign "WerReportHang"
((ptr void) @-> (ptr uint16_t) @-> returning int32_t)
(* hwndHungApp : HWND -> (ptr void) *)
(* pwzHungApplicationName : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library faultrep (t "faultrep.dll"))
(cffi:use-foreign-library faultrep)
(cffi:defcfun ("WerReportHang" wer-report-hang :convention :stdcall) :int32
(hwnd-hung-app :pointer) ; HWND
(pwz-hung-application-name (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WerReportHang = Win32::API::More->new('faultrep',
'int WerReportHang(HANDLE hwndHungApp, LPCWSTR pwzHungApplicationName)');
# my $ret = $WerReportHang->Call($hwndHungApp, $pwzHungApplicationName);
# hwndHungApp : HWND -> HANDLE
# pwzHungApplicationName : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。