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