Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Etw › TraceQueryInformation

TraceQueryInformation

関数
トレースセッションの設定情報や状態を照会する。
DLLADVAPI32.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

WIN32_ERROR TraceQueryInformation(
    ULONGLONG TraceId,
    TRACE_QUERY_INFO_CLASS InformationClass,
    void* TraceInformation,
    DWORD InformationLength,
    DWORD* ReturnLength   // optional
);

パラメーター

名前方向
TraceIdULONGLONGin
InformationClassTRACE_QUERY_INFO_CLASSin
TraceInformationvoid*out
InformationLengthDWORDin
ReturnLengthDWORD*outoptional

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR TraceQueryInformation(
    ULONGLONG TraceId,
    TRACE_QUERY_INFO_CLASS InformationClass,
    void* TraceInformation,
    DWORD InformationLength,
    DWORD* ReturnLength   // optional
);
[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern uint TraceQueryInformation(
    ulong TraceId,   // ULONGLONG
    int InformationClass,   // TRACE_QUERY_INFO_CLASS
    IntPtr TraceInformation,   // void* out
    uint InformationLength,   // DWORD
    IntPtr ReturnLength   // DWORD* optional, out
);
<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function TraceQueryInformation(
    TraceId As ULong,   ' ULONGLONG
    InformationClass As Integer,   ' TRACE_QUERY_INFO_CLASS
    TraceInformation As IntPtr,   ' void* out
    InformationLength As UInteger,   ' DWORD
    ReturnLength As IntPtr   ' DWORD* optional, out
) As UInteger
End Function
' TraceId : ULONGLONG
' InformationClass : TRACE_QUERY_INFO_CLASS
' TraceInformation : void* out
' InformationLength : DWORD
' ReturnLength : DWORD* optional, out
Declare PtrSafe Function TraceQueryInformation Lib "advapi32" ( _
    ByVal TraceId As LongLong, _
    ByVal InformationClass As Long, _
    ByVal TraceInformation As LongPtr, _
    ByVal InformationLength As Long, _
    ByVal ReturnLength As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

TraceQueryInformation = ctypes.windll.advapi32.TraceQueryInformation
TraceQueryInformation.restype = wintypes.DWORD
TraceQueryInformation.argtypes = [
    ctypes.c_ulonglong,  # TraceId : ULONGLONG
    ctypes.c_int,  # InformationClass : TRACE_QUERY_INFO_CLASS
    ctypes.POINTER(None),  # TraceInformation : void* out
    wintypes.DWORD,  # InformationLength : DWORD
    ctypes.POINTER(wintypes.DWORD),  # ReturnLength : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
TraceQueryInformation = Fiddle::Function.new(
  lib['TraceQueryInformation'],
  [
    -Fiddle::TYPE_LONG_LONG,  # TraceId : ULONGLONG
    Fiddle::TYPE_INT,  # InformationClass : TRACE_QUERY_INFO_CLASS
    Fiddle::TYPE_VOIDP,  # TraceInformation : void* out
    -Fiddle::TYPE_INT,  # InformationLength : DWORD
    Fiddle::TYPE_VOIDP,  # ReturnLength : DWORD* optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn TraceQueryInformation(
        TraceId: u64,  // ULONGLONG
        InformationClass: i32,  // TRACE_QUERY_INFO_CLASS
        TraceInformation: *mut (),  // void* out
        InformationLength: u32,  // DWORD
        ReturnLength: *mut u32  // DWORD* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern uint TraceQueryInformation(ulong TraceId, int InformationClass, IntPtr TraceInformation, uint InformationLength, IntPtr ReturnLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_TraceQueryInformation' -Namespace Win32 -PassThru
# $api::TraceQueryInformation(TraceId, InformationClass, TraceInformation, InformationLength, ReturnLength)
#uselib "ADVAPI32.dll"
#func global TraceQueryInformation "TraceQueryInformation" sptr, sptr, sptr, sptr, sptr
; TraceQueryInformation TraceId, InformationClass, TraceInformation, InformationLength, varptr(ReturnLength)   ; 戻り値は stat
; TraceId : ULONGLONG -> "sptr"
; InformationClass : TRACE_QUERY_INFO_CLASS -> "sptr"
; TraceInformation : void* out -> "sptr"
; InformationLength : DWORD -> "sptr"
; ReturnLength : DWORD* optional, out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ADVAPI32.dll"
#cfunc global TraceQueryInformation "TraceQueryInformation" int64, int, sptr, int, var
; res = TraceQueryInformation(TraceId, InformationClass, TraceInformation, InformationLength, ReturnLength)
; TraceId : ULONGLONG -> "int64"
; InformationClass : TRACE_QUERY_INFO_CLASS -> "int"
; TraceInformation : void* out -> "sptr"
; InformationLength : DWORD -> "int"
; ReturnLength : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; WIN32_ERROR TraceQueryInformation(ULONGLONG TraceId, TRACE_QUERY_INFO_CLASS InformationClass, void* TraceInformation, DWORD InformationLength, DWORD* ReturnLength)
#uselib "ADVAPI32.dll"
#cfunc global TraceQueryInformation "TraceQueryInformation" int64, int, intptr, int, var
; res = TraceQueryInformation(TraceId, InformationClass, TraceInformation, InformationLength, ReturnLength)
; TraceId : ULONGLONG -> "int64"
; InformationClass : TRACE_QUERY_INFO_CLASS -> "int"
; TraceInformation : void* out -> "intptr"
; InformationLength : DWORD -> "int"
; ReturnLength : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procTraceQueryInformation = advapi32.NewProc("TraceQueryInformation")
)

// TraceId (ULONGLONG), InformationClass (TRACE_QUERY_INFO_CLASS), TraceInformation (void* out), InformationLength (DWORD), ReturnLength (DWORD* optional, out)
r1, _, err := procTraceQueryInformation.Call(
	uintptr(TraceId),
	uintptr(InformationClass),
	uintptr(TraceInformation),
	uintptr(InformationLength),
	uintptr(ReturnLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function TraceQueryInformation(
  TraceId: UInt64;   // ULONGLONG
  InformationClass: Integer;   // TRACE_QUERY_INFO_CLASS
  TraceInformation: Pointer;   // void* out
  InformationLength: DWORD;   // DWORD
  ReturnLength: Pointer   // DWORD* optional, out
): DWORD; stdcall;
  external 'ADVAPI32.dll' name 'TraceQueryInformation';
result := DllCall("ADVAPI32\TraceQueryInformation"
    , "Int64", TraceId   ; ULONGLONG
    , "Int", InformationClass   ; TRACE_QUERY_INFO_CLASS
    , "Ptr", TraceInformation   ; void* out
    , "UInt", InformationLength   ; DWORD
    , "Ptr", ReturnLength   ; DWORD* optional, out
    , "UInt")   ; return: WIN32_ERROR
●TraceQueryInformation(TraceId, InformationClass, TraceInformation, InformationLength, ReturnLength) = DLL("ADVAPI32.dll", "dword TraceQueryInformation(qword, int, void*, dword, void*)")
# 呼び出し: TraceQueryInformation(TraceId, InformationClass, TraceInformation, InformationLength, ReturnLength)
# TraceId : ULONGLONG -> "qword"
# InformationClass : TRACE_QUERY_INFO_CLASS -> "int"
# TraceInformation : void* out -> "void*"
# InformationLength : DWORD -> "dword"
# ReturnLength : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。