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

EnumerateTraceGuids

関数
システムに登録されているトレースGUIDを列挙する。
DLLADVAPI32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

WIN32_ERROR EnumerateTraceGuids(
    TRACE_GUID_PROPERTIES** GuidPropertiesArray,
    DWORD PropertyArrayCount,
    DWORD* GuidCount
);

パラメーター

名前方向
GuidPropertiesArrayTRACE_GUID_PROPERTIES**inout
PropertyArrayCountDWORDin
GuidCountDWORD*out

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR EnumerateTraceGuids(
    TRACE_GUID_PROPERTIES** GuidPropertiesArray,
    DWORD PropertyArrayCount,
    DWORD* GuidCount
);
[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern uint EnumerateTraceGuids(
    IntPtr GuidPropertiesArray,   // TRACE_GUID_PROPERTIES** in/out
    uint PropertyArrayCount,   // DWORD
    out uint GuidCount   // DWORD* out
);
<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function EnumerateTraceGuids(
    GuidPropertiesArray As IntPtr,   ' TRACE_GUID_PROPERTIES** in/out
    PropertyArrayCount As UInteger,   ' DWORD
    <Out> ByRef GuidCount As UInteger   ' DWORD* out
) As UInteger
End Function
' GuidPropertiesArray : TRACE_GUID_PROPERTIES** in/out
' PropertyArrayCount : DWORD
' GuidCount : DWORD* out
Declare PtrSafe Function EnumerateTraceGuids Lib "advapi32" ( _
    ByVal GuidPropertiesArray As LongPtr, _
    ByVal PropertyArrayCount As Long, _
    ByRef GuidCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EnumerateTraceGuids = ctypes.windll.advapi32.EnumerateTraceGuids
EnumerateTraceGuids.restype = wintypes.DWORD
EnumerateTraceGuids.argtypes = [
    ctypes.c_void_p,  # GuidPropertiesArray : TRACE_GUID_PROPERTIES** in/out
    wintypes.DWORD,  # PropertyArrayCount : DWORD
    ctypes.POINTER(wintypes.DWORD),  # GuidCount : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
EnumerateTraceGuids = Fiddle::Function.new(
  lib['EnumerateTraceGuids'],
  [
    Fiddle::TYPE_VOIDP,  # GuidPropertiesArray : TRACE_GUID_PROPERTIES** in/out
    -Fiddle::TYPE_INT,  # PropertyArrayCount : DWORD
    Fiddle::TYPE_VOIDP,  # GuidCount : DWORD* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn EnumerateTraceGuids(
        GuidPropertiesArray: *mut *mut TRACE_GUID_PROPERTIES,  // TRACE_GUID_PROPERTIES** in/out
        PropertyArrayCount: u32,  // DWORD
        GuidCount: *mut u32  // DWORD* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern uint EnumerateTraceGuids(IntPtr GuidPropertiesArray, uint PropertyArrayCount, out uint GuidCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_EnumerateTraceGuids' -Namespace Win32 -PassThru
# $api::EnumerateTraceGuids(GuidPropertiesArray, PropertyArrayCount, GuidCount)
#uselib "ADVAPI32.dll"
#func global EnumerateTraceGuids "EnumerateTraceGuids" sptr, sptr, sptr
; EnumerateTraceGuids varptr(GuidPropertiesArray), PropertyArrayCount, varptr(GuidCount)   ; 戻り値は stat
; GuidPropertiesArray : TRACE_GUID_PROPERTIES** in/out -> "sptr"
; PropertyArrayCount : DWORD -> "sptr"
; GuidCount : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ADVAPI32.dll"
#cfunc global EnumerateTraceGuids "EnumerateTraceGuids" var, int, var
; res = EnumerateTraceGuids(GuidPropertiesArray, PropertyArrayCount, GuidCount)
; GuidPropertiesArray : TRACE_GUID_PROPERTIES** in/out -> "var"
; PropertyArrayCount : DWORD -> "int"
; GuidCount : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR EnumerateTraceGuids(TRACE_GUID_PROPERTIES** GuidPropertiesArray, DWORD PropertyArrayCount, DWORD* GuidCount)
#uselib "ADVAPI32.dll"
#cfunc global EnumerateTraceGuids "EnumerateTraceGuids" var, int, var
; res = EnumerateTraceGuids(GuidPropertiesArray, PropertyArrayCount, GuidCount)
; GuidPropertiesArray : TRACE_GUID_PROPERTIES** in/out -> "var"
; PropertyArrayCount : DWORD -> "int"
; GuidCount : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procEnumerateTraceGuids = advapi32.NewProc("EnumerateTraceGuids")
)

// GuidPropertiesArray (TRACE_GUID_PROPERTIES** in/out), PropertyArrayCount (DWORD), GuidCount (DWORD* out)
r1, _, err := procEnumerateTraceGuids.Call(
	uintptr(GuidPropertiesArray),
	uintptr(PropertyArrayCount),
	uintptr(GuidCount),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function EnumerateTraceGuids(
  GuidPropertiesArray: Pointer;   // TRACE_GUID_PROPERTIES** in/out
  PropertyArrayCount: DWORD;   // DWORD
  GuidCount: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'ADVAPI32.dll' name 'EnumerateTraceGuids';
result := DllCall("ADVAPI32\EnumerateTraceGuids"
    , "Ptr", GuidPropertiesArray   ; TRACE_GUID_PROPERTIES** in/out
    , "UInt", PropertyArrayCount   ; DWORD
    , "Ptr", GuidCount   ; DWORD* out
    , "UInt")   ; return: WIN32_ERROR
●EnumerateTraceGuids(GuidPropertiesArray, PropertyArrayCount, GuidCount) = DLL("ADVAPI32.dll", "dword EnumerateTraceGuids(void*, dword, void*)")
# 呼び出し: EnumerateTraceGuids(GuidPropertiesArray, PropertyArrayCount, GuidCount)
# GuidPropertiesArray : TRACE_GUID_PROPERTIES** in/out -> "void*"
# PropertyArrayCount : DWORD -> "dword"
# GuidCount : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。