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

WerStoreGetReportCount

関数
WERストア内のレポート件数を取得する。
DLLwer.dll呼出規約winapi

シグネチャ

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

HRESULT WerStoreGetReportCount(
    HREPORTSTORE hReportStore,
    DWORD* pdwReportCount
);

パラメーター

名前方向説明
hReportStoreHREPORTSTOREin対象レポートストアのHREPORTSTOREハンドル。
pdwReportCountDWORD*outストア内のレポート総数を受け取るDWORDへのポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WerStoreGetReportCount(
    HREPORTSTORE hReportStore,
    DWORD* pdwReportCount
);
[DllImport("wer.dll", ExactSpelling = true)]
static extern int WerStoreGetReportCount(
    IntPtr hReportStore,   // HREPORTSTORE
    out uint pdwReportCount   // DWORD* out
);
<DllImport("wer.dll", ExactSpelling:=True)>
Public Shared Function WerStoreGetReportCount(
    hReportStore As IntPtr,   ' HREPORTSTORE
    <Out> ByRef pdwReportCount As UInteger   ' DWORD* out
) As Integer
End Function
' hReportStore : HREPORTSTORE
' pdwReportCount : DWORD* out
Declare PtrSafe Function WerStoreGetReportCount Lib "wer" ( _
    ByVal hReportStore As LongPtr, _
    ByRef pdwReportCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WerStoreGetReportCount = ctypes.windll.wer.WerStoreGetReportCount
WerStoreGetReportCount.restype = ctypes.c_int
WerStoreGetReportCount.argtypes = [
    wintypes.HANDLE,  # hReportStore : HREPORTSTORE
    ctypes.POINTER(wintypes.DWORD),  # pdwReportCount : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wer = windows.NewLazySystemDLL("wer.dll")
	procWerStoreGetReportCount = wer.NewProc("WerStoreGetReportCount")
)

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

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

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

foreign import stdcall safe "WerStoreGetReportCount"
  c_WerStoreGetReportCount :: Ptr () -> Ptr Word32 -> IO Int32
-- hReportStore : HREPORTSTORE -> Ptr ()
-- pdwReportCount : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let werstoregetreportcount =
  foreign "WerStoreGetReportCount"
    ((ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* hReportStore : HREPORTSTORE -> (ptr void) *)
(* pdwReportCount : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wer (t "wer.dll"))
(cffi:use-foreign-library wer)

(cffi:defcfun ("WerStoreGetReportCount" wer-store-get-report-count :convention :stdcall) :int32
  (h-report-store :pointer)   ; HREPORTSTORE
  (pdw-report-count :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WerStoreGetReportCount = Win32::API::More->new('wer',
    'int WerStoreGetReportCount(HANDLE hReportStore, LPVOID pdwReportCount)');
# my $ret = $WerStoreGetReportCount->Call($hReportStore, $pdwReportCount);
# hReportStore : HREPORTSTORE -> HANDLE
# pdwReportCount : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。