ホーム › 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)。const std = @import("std");
extern "diagnosticdataquery" fn DdqExtractDiagnosticReport(
hSession: ?*anyopaque, // HDIAGNOSTIC_DATA_QUERY_SESSION
reportStoreType: u32, // DWORD
reportKey: [*c]const u16, // LPCWSTR
destinationPath: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc DdqExtractDiagnosticReport(
hSession: pointer, # HDIAGNOSTIC_DATA_QUERY_SESSION
reportStoreType: uint32, # DWORD
reportKey: WideCString, # LPCWSTR
destinationPath: WideCString # LPCWSTR
): int32 {.importc: "DdqExtractDiagnosticReport", stdcall, dynlib: "DiagnosticDataQuery.dll".}pragma(lib, "diagnosticdataquery");
extern(Windows)
int DdqExtractDiagnosticReport(
void* hSession, // HDIAGNOSTIC_DATA_QUERY_SESSION
uint reportStoreType, // DWORD
const(wchar)* reportKey, // LPCWSTR
const(wchar)* destinationPath // LPCWSTR
);ccall((:DdqExtractDiagnosticReport, "DiagnosticDataQuery.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Cwstring, Cwstring),
hSession, reportStoreType, reportKey, destinationPath)
# hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> Ptr{Cvoid}
# reportStoreType : DWORD -> UInt32
# reportKey : LPCWSTR -> Cwstring
# destinationPath : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DdqExtractDiagnosticReport(
void* hSession,
uint32_t reportStoreType,
const uint16_t* reportKey,
const uint16_t* destinationPath);
]]
local diagnosticdataquery = ffi.load("diagnosticdataquery")
-- diagnosticdataquery.DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath)
-- hSession : HDIAGNOSTIC_DATA_QUERY_SESSION
-- reportStoreType : DWORD
-- reportKey : LPCWSTR
-- destinationPath : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DiagnosticDataQuery.dll');
const DdqExtractDiagnosticReport = lib.func('__stdcall', 'DdqExtractDiagnosticReport', 'int32_t', ['void *', 'uint32_t', 'str16', 'str16']);
// DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath)
// hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> 'void *'
// reportStoreType : DWORD -> 'uint32_t'
// reportKey : LPCWSTR -> 'str16'
// destinationPath : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DiagnosticDataQuery.dll", {
DdqExtractDiagnosticReport: { parameters: ["pointer", "u32", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath)
// hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> "pointer"
// reportStoreType : DWORD -> "u32"
// reportKey : LPCWSTR -> "buffer"
// destinationPath : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DdqExtractDiagnosticReport(
void* hSession,
uint32_t reportStoreType,
const uint16_t* reportKey,
const uint16_t* destinationPath);
C, "DiagnosticDataQuery.dll");
// $ffi->DdqExtractDiagnosticReport(hSession, reportStoreType, reportKey, destinationPath);
// hSession : HDIAGNOSTIC_DATA_QUERY_SESSION
// reportStoreType : DWORD
// reportKey : LPCWSTR
// destinationPath : LPCWSTR
// 構造体/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 DdqExtractDiagnosticReport(
Pointer hSession, // HDIAGNOSTIC_DATA_QUERY_SESSION
int reportStoreType, // DWORD
WString reportKey, // LPCWSTR
WString destinationPath // LPCWSTR
);
}@[Link("diagnosticdataquery")]
lib LibDiagnosticDataQuery
fun DdqExtractDiagnosticReport = DdqExtractDiagnosticReport(
hSession : Void*, # HDIAGNOSTIC_DATA_QUERY_SESSION
reportStoreType : UInt32, # DWORD
reportKey : UInt16*, # LPCWSTR
destinationPath : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DdqExtractDiagnosticReportNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Utf16>);
typedef DdqExtractDiagnosticReportDart = int Function(Pointer<Void>, int, Pointer<Utf16>, Pointer<Utf16>);
final DdqExtractDiagnosticReport = DynamicLibrary.open('DiagnosticDataQuery.dll')
.lookupFunction<DdqExtractDiagnosticReportNative, DdqExtractDiagnosticReportDart>('DdqExtractDiagnosticReport');
// hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> Pointer<Void>
// reportStoreType : DWORD -> Uint32
// reportKey : LPCWSTR -> Pointer<Utf16>
// destinationPath : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DdqExtractDiagnosticReport(
hSession: THandle; // HDIAGNOSTIC_DATA_QUERY_SESSION
reportStoreType: DWORD; // DWORD
reportKey: PWideChar; // LPCWSTR
destinationPath: PWideChar // LPCWSTR
): Integer; stdcall;
external 'DiagnosticDataQuery.dll' name 'DdqExtractDiagnosticReport';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DdqExtractDiagnosticReport"
c_DdqExtractDiagnosticReport :: Ptr () -> Word32 -> CWString -> CWString -> IO Int32
-- hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> Ptr ()
-- reportStoreType : DWORD -> Word32
-- reportKey : LPCWSTR -> CWString
-- destinationPath : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ddqextractdiagnosticreport =
foreign "DdqExtractDiagnosticReport"
((ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> (ptr void) *)
(* reportStoreType : DWORD -> uint32_t *)
(* reportKey : LPCWSTR -> (ptr uint16_t) *)
(* destinationPath : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library diagnosticdataquery (t "DiagnosticDataQuery.dll"))
(cffi:use-foreign-library diagnosticdataquery)
(cffi:defcfun ("DdqExtractDiagnosticReport" ddq-extract-diagnostic-report :convention :stdcall) :int32
(h-session :pointer) ; HDIAGNOSTIC_DATA_QUERY_SESSION
(report-store-type :uint32) ; DWORD
(report-key (:string :encoding :utf-16le)) ; LPCWSTR
(destination-path (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DdqExtractDiagnosticReport = Win32::API::More->new('DiagnosticDataQuery',
'int DdqExtractDiagnosticReport(HANDLE hSession, DWORD reportStoreType, LPCWSTR reportKey, LPCWSTR destinationPath)');
# my $ret = $DdqExtractDiagnosticReport->Call($hSession, $reportStoreType, $reportKey, $destinationPath);
# hSession : HDIAGNOSTIC_DATA_QUERY_SESSION -> HANDLE
# reportStoreType : DWORD -> DWORD
# reportKey : LPCWSTR -> LPCWSTR
# destinationPath : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。