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