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

WerStoreQueryReportMetadataV3

関数
WERレポートのメタデータをV3形式で取得する。
DLLwer.dll呼出規約winapi

シグネチャ

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

HRESULT WerStoreQueryReportMetadataV3(
    HREPORTSTORE hReportStore,
    LPCWSTR pszReportKey,
    WER_REPORT_METADATA_V3* pReportMetadata
);

パラメーター

名前方向説明
hReportStoreHREPORTSTOREin対象レポートストアのHREPORTSTOREハンドル。
pszReportKeyLPCWSTRinメタデータを取得するレポートのキー文字列。
pReportMetadataWER_REPORT_METADATA_V3*outV3形式のメタデータを受け取るWER_REPORT_METADATA_V3構造体へのポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WerStoreQueryReportMetadataV3(
    HREPORTSTORE hReportStore,
    LPCWSTR pszReportKey,
    WER_REPORT_METADATA_V3* pReportMetadata
);
[DllImport("wer.dll", ExactSpelling = true)]
static extern int WerStoreQueryReportMetadataV3(
    IntPtr hReportStore,   // HREPORTSTORE
    [MarshalAs(UnmanagedType.LPWStr)] string pszReportKey,   // LPCWSTR
    IntPtr pReportMetadata   // WER_REPORT_METADATA_V3* out
);
<DllImport("wer.dll", ExactSpelling:=True)>
Public Shared Function WerStoreQueryReportMetadataV3(
    hReportStore As IntPtr,   ' HREPORTSTORE
    <MarshalAs(UnmanagedType.LPWStr)> pszReportKey As String,   ' LPCWSTR
    pReportMetadata As IntPtr   ' WER_REPORT_METADATA_V3* out
) As Integer
End Function
' hReportStore : HREPORTSTORE
' pszReportKey : LPCWSTR
' pReportMetadata : WER_REPORT_METADATA_V3* out
Declare PtrSafe Function WerStoreQueryReportMetadataV3 Lib "wer" ( _
    ByVal hReportStore As LongPtr, _
    ByVal pszReportKey As LongPtr, _
    ByVal pReportMetadata As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WerStoreQueryReportMetadataV3 = ctypes.windll.wer.WerStoreQueryReportMetadataV3
WerStoreQueryReportMetadataV3.restype = ctypes.c_int
WerStoreQueryReportMetadataV3.argtypes = [
    wintypes.HANDLE,  # hReportStore : HREPORTSTORE
    wintypes.LPCWSTR,  # pszReportKey : LPCWSTR
    ctypes.c_void_p,  # pReportMetadata : WER_REPORT_METADATA_V3* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wer.dll')
WerStoreQueryReportMetadataV3 = Fiddle::Function.new(
  lib['WerStoreQueryReportMetadataV3'],
  [
    Fiddle::TYPE_VOIDP,  # hReportStore : HREPORTSTORE
    Fiddle::TYPE_VOIDP,  # pszReportKey : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pReportMetadata : WER_REPORT_METADATA_V3* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wer")]
extern "system" {
    fn WerStoreQueryReportMetadataV3(
        hReportStore: *mut core::ffi::c_void,  // HREPORTSTORE
        pszReportKey: *const u16,  // LPCWSTR
        pReportMetadata: *mut WER_REPORT_METADATA_V3  // WER_REPORT_METADATA_V3* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wer.dll")]
public static extern int WerStoreQueryReportMetadataV3(IntPtr hReportStore, [MarshalAs(UnmanagedType.LPWStr)] string pszReportKey, IntPtr pReportMetadata);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wer_WerStoreQueryReportMetadataV3' -Namespace Win32 -PassThru
# $api::WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata)
#uselib "wer.dll"
#func global WerStoreQueryReportMetadataV3 "WerStoreQueryReportMetadataV3" sptr, sptr, sptr
; WerStoreQueryReportMetadataV3 hReportStore, pszReportKey, varptr(pReportMetadata)   ; 戻り値は stat
; hReportStore : HREPORTSTORE -> "sptr"
; pszReportKey : LPCWSTR -> "sptr"
; pReportMetadata : WER_REPORT_METADATA_V3* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wer.dll"
#cfunc global WerStoreQueryReportMetadataV3 "WerStoreQueryReportMetadataV3" sptr, wstr, var
; res = WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata)
; hReportStore : HREPORTSTORE -> "sptr"
; pszReportKey : LPCWSTR -> "wstr"
; pReportMetadata : WER_REPORT_METADATA_V3* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WerStoreQueryReportMetadataV3(HREPORTSTORE hReportStore, LPCWSTR pszReportKey, WER_REPORT_METADATA_V3* pReportMetadata)
#uselib "wer.dll"
#cfunc global WerStoreQueryReportMetadataV3 "WerStoreQueryReportMetadataV3" intptr, wstr, var
; res = WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata)
; hReportStore : HREPORTSTORE -> "intptr"
; pszReportKey : LPCWSTR -> "wstr"
; pReportMetadata : WER_REPORT_METADATA_V3* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wer = windows.NewLazySystemDLL("wer.dll")
	procWerStoreQueryReportMetadataV3 = wer.NewProc("WerStoreQueryReportMetadataV3")
)

// hReportStore (HREPORTSTORE), pszReportKey (LPCWSTR), pReportMetadata (WER_REPORT_METADATA_V3* out)
r1, _, err := procWerStoreQueryReportMetadataV3.Call(
	uintptr(hReportStore),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszReportKey))),
	uintptr(pReportMetadata),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WerStoreQueryReportMetadataV3(
  hReportStore: THandle;   // HREPORTSTORE
  pszReportKey: PWideChar;   // LPCWSTR
  pReportMetadata: Pointer   // WER_REPORT_METADATA_V3* out
): Integer; stdcall;
  external 'wer.dll' name 'WerStoreQueryReportMetadataV3';
result := DllCall("wer\WerStoreQueryReportMetadataV3"
    , "Ptr", hReportStore   ; HREPORTSTORE
    , "WStr", pszReportKey   ; LPCWSTR
    , "Ptr", pReportMetadata   ; WER_REPORT_METADATA_V3* out
    , "Int")   ; return: HRESULT
●WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata) = DLL("wer.dll", "int WerStoreQueryReportMetadataV3(void*, char*, void*)")
# 呼び出し: WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata)
# hReportStore : HREPORTSTORE -> "void*"
# pszReportKey : LPCWSTR -> "char*"
# pReportMetadata : WER_REPORT_METADATA_V3* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wer" fn WerStoreQueryReportMetadataV3(
    hReportStore: ?*anyopaque, // HREPORTSTORE
    pszReportKey: [*c]const u16, // LPCWSTR
    pReportMetadata: [*c]WER_REPORT_METADATA_V3 // WER_REPORT_METADATA_V3* out
) callconv(std.os.windows.WINAPI) i32;
proc WerStoreQueryReportMetadataV3(
    hReportStore: pointer,  # HREPORTSTORE
    pszReportKey: WideCString,  # LPCWSTR
    pReportMetadata: ptr WER_REPORT_METADATA_V3  # WER_REPORT_METADATA_V3* out
): int32 {.importc: "WerStoreQueryReportMetadataV3", stdcall, dynlib: "wer.dll".}
pragma(lib, "wer");
extern(Windows)
int WerStoreQueryReportMetadataV3(
    void* hReportStore,   // HREPORTSTORE
    const(wchar)* pszReportKey,   // LPCWSTR
    WER_REPORT_METADATA_V3* pReportMetadata   // WER_REPORT_METADATA_V3* out
);
ccall((:WerStoreQueryReportMetadataV3, "wer.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cwstring, Ptr{WER_REPORT_METADATA_V3}),
      hReportStore, pszReportKey, pReportMetadata)
# hReportStore : HREPORTSTORE -> Ptr{Cvoid}
# pszReportKey : LPCWSTR -> Cwstring
# pReportMetadata : WER_REPORT_METADATA_V3* out -> Ptr{WER_REPORT_METADATA_V3}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WerStoreQueryReportMetadataV3(
    void* hReportStore,
    const uint16_t* pszReportKey,
    void* pReportMetadata);
]]
local wer = ffi.load("wer")
-- wer.WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata)
-- hReportStore : HREPORTSTORE
-- pszReportKey : LPCWSTR
-- pReportMetadata : WER_REPORT_METADATA_V3* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wer.dll');
const WerStoreQueryReportMetadataV3 = lib.func('__stdcall', 'WerStoreQueryReportMetadataV3', 'int32_t', ['void *', 'str16', 'void *']);
// WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata)
// hReportStore : HREPORTSTORE -> 'void *'
// pszReportKey : LPCWSTR -> 'str16'
// pReportMetadata : WER_REPORT_METADATA_V3* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wer.dll", {
  WerStoreQueryReportMetadataV3: { parameters: ["pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata)
// hReportStore : HREPORTSTORE -> "pointer"
// pszReportKey : LPCWSTR -> "buffer"
// pReportMetadata : WER_REPORT_METADATA_V3* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WerStoreQueryReportMetadataV3(
    void* hReportStore,
    const uint16_t* pszReportKey,
    void* pReportMetadata);
C, "wer.dll");
// $ffi->WerStoreQueryReportMetadataV3(hReportStore, pszReportKey, pReportMetadata);
// hReportStore : HREPORTSTORE
// pszReportKey : LPCWSTR
// pReportMetadata : WER_REPORT_METADATA_V3* 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 WerStoreQueryReportMetadataV3(
        Pointer hReportStore,   // HREPORTSTORE
        WString pszReportKey,   // LPCWSTR
        Pointer pReportMetadata   // WER_REPORT_METADATA_V3* out
    );
}
@[Link("wer")]
lib Libwer
  fun WerStoreQueryReportMetadataV3 = WerStoreQueryReportMetadataV3(
    hReportStore : Void*,   # HREPORTSTORE
    pszReportKey : UInt16*,   # LPCWSTR
    pReportMetadata : WER_REPORT_METADATA_V3*   # WER_REPORT_METADATA_V3* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WerStoreQueryReportMetadataV3Native = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
typedef WerStoreQueryReportMetadataV3Dart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
final WerStoreQueryReportMetadataV3 = DynamicLibrary.open('wer.dll')
    .lookupFunction<WerStoreQueryReportMetadataV3Native, WerStoreQueryReportMetadataV3Dart>('WerStoreQueryReportMetadataV3');
// hReportStore : HREPORTSTORE -> Pointer<Void>
// pszReportKey : LPCWSTR -> Pointer<Utf16>
// pReportMetadata : WER_REPORT_METADATA_V3* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WerStoreQueryReportMetadataV3(
  hReportStore: THandle;   // HREPORTSTORE
  pszReportKey: PWideChar;   // LPCWSTR
  pReportMetadata: Pointer   // WER_REPORT_METADATA_V3* out
): Integer; stdcall;
  external 'wer.dll' name 'WerStoreQueryReportMetadataV3';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WerStoreQueryReportMetadataV3"
  c_WerStoreQueryReportMetadataV3 :: Ptr () -> CWString -> Ptr () -> IO Int32
-- hReportStore : HREPORTSTORE -> Ptr ()
-- pszReportKey : LPCWSTR -> CWString
-- pReportMetadata : WER_REPORT_METADATA_V3* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let werstorequeryreportmetadatav3 =
  foreign "WerStoreQueryReportMetadataV3"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* hReportStore : HREPORTSTORE -> (ptr void) *)
(* pszReportKey : LPCWSTR -> (ptr uint16_t) *)
(* pReportMetadata : WER_REPORT_METADATA_V3* 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 ("WerStoreQueryReportMetadataV3" wer-store-query-report-metadata-v3 :convention :stdcall) :int32
  (h-report-store :pointer)   ; HREPORTSTORE
  (psz-report-key (:string :encoding :utf-16le))   ; LPCWSTR
  (p-report-metadata :pointer))   ; WER_REPORT_METADATA_V3* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WerStoreQueryReportMetadataV3 = Win32::API::More->new('wer',
    'int WerStoreQueryReportMetadataV3(HANDLE hReportStore, LPCWSTR pszReportKey, LPVOID pReportMetadata)');
# my $ret = $WerStoreQueryReportMetadataV3->Call($hReportStore, $pszReportKey, $pReportMetadata);
# hReportStore : HREPORTSTORE -> HANDLE
# pszReportKey : LPCWSTR -> LPCWSTR
# pReportMetadata : WER_REPORT_METADATA_V3* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型