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