ホーム › Security.DiagnosticDataQuery › DdqExtractDiagnosticReport
DdqExtractDiagnosticReport
関数診断レポートを指定パスに抽出して保存する。
シグネチャ
// DiagnosticDataQuery.dll
#include <windows.h>
HRESULT DdqExtractDiagnosticReport(
HDIAGNOSTIC_DATA_QUERY_SESSION hSession,
DWORD reportStoreType,
LPCWSTR reportKey,
LPCWSTR destinationPath
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hSession | HDIAGNOSTIC_DATA_QUERY_SESSION | in |
| reportStoreType | DWORD | in |
| reportKey | LPCWSTR | in |
| destinationPath | LPCWSTR | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// DiagnosticDataQuery.dll
#include <windows.h>
HRESULT DdqExtractDiagnosticReport(
HDIAGNOSTIC_DATA_QUERY_SESSION hSession,
DWORD reportStoreType,
LPCWSTR reportKey,
LPCWSTR destinationPath
);[DllImport("DiagnosticDataQuery.dll", ExactSpelling = true)]
static extern int DdqExtractDiagnosticReport(
IntPtr hSession, // HDIAGNOSTIC_DATA_QUERY_SESSION
uint reportStoreType, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string reportKey, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string destinationPath // LPCWSTR
);<DllImport("DiagnosticDataQuery.dll", ExactSpelling:=True)>
Public Shared Function DdqExtractDiagnosticReport(
hSession As IntPtr, ' HDIAGNOSTIC_DATA_QUERY_SESSION
reportStoreType As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> reportKey As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> destinationPath As String ' LPCWSTR
) As Integer
End Function' hSession : HDIAGNOSTIC_DATA_QUERY_SESSION
' reportStoreType : DWORD
' reportKey : LPCWSTR
' destinationPath : LPCWSTR
Declare PtrSafe Function DdqExtractDiagnosticReport Lib "diagnosticdataquery" ( _
ByVal hSession As LongPtr, _
ByVal reportStoreType As Long, _
ByVal reportKey As LongPtr, _
ByVal destinationPath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DdqExtractDiagnosticReport = ctypes.windll.diagnosticdataquery.DdqExtractDiagnosticReport
DdqExtractDiagnosticReport.restype = ctypes.c_int
DdqExtractDiagnosticReport.argtypes = [
wintypes.HANDLE, # hSession : HDIAGNOSTIC_DATA_QUERY_SESSION
wintypes.DWORD, # reportStoreType : DWORD
wintypes.LPCWSTR, # reportKey : LPCWSTR
wintypes.LPCWSTR, # destinationPath : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DiagnosticDataQuery.dll')
DdqExtractDiagnosticReport = Fiddle::Function.new(
lib['DdqExtractDiagnosticReport'],
[
Fiddle::TYPE_VOIDP, # hSession : HDIAGNOSTIC_DATA_QUERY_SESSION
-Fiddle::TYPE_INT, # reportStoreType : DWORD
Fiddle::TYPE_VOIDP, # reportKey : LPCWSTR
Fiddle::TYPE_VOIDP, # destinationPath : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "diagnosticdataquery")]
extern "system" {
fn DdqExtractDiagnosticReport(
hSession: *mut core::ffi::c_void, // HDIAGNOSTIC_DATA_QUERY_SESSION
reportStoreType: u32, // DWORD
reportKey: *const u16, // LPCWSTR
destinationPath: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DiagnosticDataQuery.dll")]
public static extern int DdqExtractDiagnosticReport(IntPtr hSession, uint reportStoreType, [MarshalAs(UnmanagedType.LPWStr)] string reportKey, [MarshalAs(UnmanagedType.LPWStr)] string destinationPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DiagnosticDataQuery_DdqExtractDiagnosticReport' -Namespace Win32 -PassThru
# $api::DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath)#uselib "DiagnosticDataQuery.dll"
#func global DdqExtractDiagnosticReport "DdqExtractDiagnosticReport" sptr, sptr, sptr, sptr
; DdqExtractDiagnosticReport hSession, reportStoreType, reportKey, destinationPath ; 戻り値は stat
; hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> "sptr"
; reportStoreType : DWORD -> "sptr"
; reportKey : LPCWSTR -> "sptr"
; destinationPath : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "DiagnosticDataQuery.dll"
#cfunc global DdqExtractDiagnosticReport "DdqExtractDiagnosticReport" sptr, int, wstr, wstr
; res = DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath)
; hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> "sptr"
; reportStoreType : DWORD -> "int"
; reportKey : LPCWSTR -> "wstr"
; destinationPath : LPCWSTR -> "wstr"; HRESULT DdqExtractDiagnosticReport(HDIAGNOSTIC_DATA_QUERY_SESSION hSession, DWORD reportStoreType, LPCWSTR reportKey, LPCWSTR destinationPath)
#uselib "DiagnosticDataQuery.dll"
#cfunc global DdqExtractDiagnosticReport "DdqExtractDiagnosticReport" intptr, int, wstr, wstr
; res = DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath)
; hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> "intptr"
; reportStoreType : DWORD -> "int"
; reportKey : LPCWSTR -> "wstr"
; destinationPath : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
diagnosticdataquery = windows.NewLazySystemDLL("DiagnosticDataQuery.dll")
procDdqExtractDiagnosticReport = diagnosticdataquery.NewProc("DdqExtractDiagnosticReport")
)
// hSession (HDIAGNOSTIC_DATA_QUERY_SESSION), reportStoreType (DWORD), reportKey (LPCWSTR), destinationPath (LPCWSTR)
r1, _, err := procDdqExtractDiagnosticReport.Call(
uintptr(hSession),
uintptr(reportStoreType),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(reportKey))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(destinationPath))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DdqExtractDiagnosticReport(
hSession: THandle; // HDIAGNOSTIC_DATA_QUERY_SESSION
reportStoreType: DWORD; // DWORD
reportKey: PWideChar; // LPCWSTR
destinationPath: PWideChar // LPCWSTR
): Integer; stdcall;
external 'DiagnosticDataQuery.dll' name 'DdqExtractDiagnosticReport';result := DllCall("DiagnosticDataQuery\DdqExtractDiagnosticReport"
, "Ptr", hSession ; HDIAGNOSTIC_DATA_QUERY_SESSION
, "UInt", reportStoreType ; DWORD
, "WStr", reportKey ; LPCWSTR
, "WStr", destinationPath ; LPCWSTR
, "Int") ; return: HRESULT●DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath) = DLL("DiagnosticDataQuery.dll", "int DdqExtractDiagnosticReport(void*, dword, char*, char*)")
# 呼び出し: DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath)
# hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> "void*"
# reportStoreType : DWORD -> "dword"
# reportKey : LPCWSTR -> "char*"
# destinationPath : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。