Win32 API 日本語リファレンス
ホームSecurity.DiagnosticDataQuery › DdqGetDiagnosticReportAtIndex

DdqGetDiagnosticReportAtIndex

関数
指定インデックスの診断レポートデータを取得する。
DLLDiagnosticDataQuery.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HRESULT DdqGetDiagnosticReportAtIndex(
    HDIAGNOSTIC_REPORT hReport,
    DWORD index,
    DIAGNOSTIC_REPORT_DATA* report
);

パラメーター

名前方向
hReportHDIAGNOSTIC_REPORTin
indexDWORDin
reportDIAGNOSTIC_REPORT_DATA*out

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // HRESULT
function 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)。