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

TraceSetInformation

関数
トレースセッションに対して各種設定情報を構成する。
DLLADVAPI32.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

WIN32_ERROR TraceSetInformation(
    ULONGLONG TraceId,
    TRACE_QUERY_INFO_CLASS InformationClass,
    void* TraceInformation,
    DWORD InformationLength
);

パラメーター

名前方向
TraceIdULONGLONGin
InformationClassTRACE_QUERY_INFO_CLASSin
TraceInformationvoid*in
InformationLengthDWORDin

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

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

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

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

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procTraceSetInformation = advapi32.NewProc("TraceSetInformation")
)

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