Win32 API 日本語リファレンス
ホームSystem.EventLog › EvtGetEventInfo

EvtGetEventInfo

関数
イベントの情報プロパティを取得する。
DLLwevtapi.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL EvtGetEventInfo(
    EVT_HANDLE Event,
    EVT_EVENT_PROPERTY_ID PropertyId,
    DWORD PropertyValueBufferSize,
    EVT_VARIANT* PropertyValueBuffer,   // optional
    DWORD* PropertyValueBufferUsed
);

パラメーター

名前方向
EventEVT_HANDLEin
PropertyIdEVT_EVENT_PROPERTY_IDin
PropertyValueBufferSizeDWORDin
PropertyValueBufferEVT_VARIANT*outoptional
PropertyValueBufferUsedDWORD*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL EvtGetEventInfo(
    EVT_HANDLE Event,
    EVT_EVENT_PROPERTY_ID PropertyId,
    DWORD PropertyValueBufferSize,
    EVT_VARIANT* PropertyValueBuffer,   // optional
    DWORD* PropertyValueBufferUsed
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("wevtapi.dll", SetLastError = true, ExactSpelling = true)]
static extern bool EvtGetEventInfo(
    IntPtr Event,   // EVT_HANDLE
    int PropertyId,   // EVT_EVENT_PROPERTY_ID
    uint PropertyValueBufferSize,   // DWORD
    IntPtr PropertyValueBuffer,   // EVT_VARIANT* optional, out
    out uint PropertyValueBufferUsed   // DWORD* out
);
<DllImport("wevtapi.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function EvtGetEventInfo(
    [Event] As IntPtr,   ' EVT_HANDLE
    PropertyId As Integer,   ' EVT_EVENT_PROPERTY_ID
    PropertyValueBufferSize As UInteger,   ' DWORD
    PropertyValueBuffer As IntPtr,   ' EVT_VARIANT* optional, out
    <Out> ByRef PropertyValueBufferUsed As UInteger   ' DWORD* out
) As Boolean
End Function
' Event : EVT_HANDLE
' PropertyId : EVT_EVENT_PROPERTY_ID
' PropertyValueBufferSize : DWORD
' PropertyValueBuffer : EVT_VARIANT* optional, out
' PropertyValueBufferUsed : DWORD* out
Declare PtrSafe Function EvtGetEventInfo Lib "wevtapi" ( _
    ByVal Event As LongPtr, _
    ByVal PropertyId As Long, _
    ByVal PropertyValueBufferSize As Long, _
    ByVal PropertyValueBuffer As LongPtr, _
    ByRef PropertyValueBufferUsed As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EvtGetEventInfo = ctypes.windll.wevtapi.EvtGetEventInfo
EvtGetEventInfo.restype = wintypes.BOOL
EvtGetEventInfo.argtypes = [
    ctypes.c_ssize_t,  # Event : EVT_HANDLE
    ctypes.c_int,  # PropertyId : EVT_EVENT_PROPERTY_ID
    wintypes.DWORD,  # PropertyValueBufferSize : DWORD
    ctypes.c_void_p,  # PropertyValueBuffer : EVT_VARIANT* optional, out
    ctypes.POINTER(wintypes.DWORD),  # PropertyValueBufferUsed : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wevtapi.dll')
EvtGetEventInfo = Fiddle::Function.new(
  lib['EvtGetEventInfo'],
  [
    Fiddle::TYPE_INTPTR_T,  # Event : EVT_HANDLE
    Fiddle::TYPE_INT,  # PropertyId : EVT_EVENT_PROPERTY_ID
    -Fiddle::TYPE_INT,  # PropertyValueBufferSize : DWORD
    Fiddle::TYPE_VOIDP,  # PropertyValueBuffer : EVT_VARIANT* optional, out
    Fiddle::TYPE_VOIDP,  # PropertyValueBufferUsed : DWORD* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wevtapi")]
extern "system" {
    fn EvtGetEventInfo(
        Event: isize,  // EVT_HANDLE
        PropertyId: i32,  // EVT_EVENT_PROPERTY_ID
        PropertyValueBufferSize: u32,  // DWORD
        PropertyValueBuffer: *mut EVT_VARIANT,  // EVT_VARIANT* optional, out
        PropertyValueBufferUsed: *mut u32  // DWORD* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("wevtapi.dll", SetLastError = true)]
public static extern bool EvtGetEventInfo(IntPtr Event, int PropertyId, uint PropertyValueBufferSize, IntPtr PropertyValueBuffer, out uint PropertyValueBufferUsed);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wevtapi_EvtGetEventInfo' -Namespace Win32 -PassThru
# $api::EvtGetEventInfo(Event, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
#uselib "wevtapi.dll"
#func global EvtGetEventInfo "EvtGetEventInfo" sptr, sptr, sptr, sptr, sptr
; EvtGetEventInfo Event, PropertyId, PropertyValueBufferSize, varptr(PropertyValueBuffer), varptr(PropertyValueBufferUsed)   ; 戻り値は stat
; Event : EVT_HANDLE -> "sptr"
; PropertyId : EVT_EVENT_PROPERTY_ID -> "sptr"
; PropertyValueBufferSize : DWORD -> "sptr"
; PropertyValueBuffer : EVT_VARIANT* optional, out -> "sptr"
; PropertyValueBufferUsed : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wevtapi.dll"
#cfunc global EvtGetEventInfo "EvtGetEventInfo" sptr, int, int, var, var
; res = EvtGetEventInfo(Event, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
; Event : EVT_HANDLE -> "sptr"
; PropertyId : EVT_EVENT_PROPERTY_ID -> "int"
; PropertyValueBufferSize : DWORD -> "int"
; PropertyValueBuffer : EVT_VARIANT* optional, out -> "var"
; PropertyValueBufferUsed : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL EvtGetEventInfo(EVT_HANDLE Event, EVT_EVENT_PROPERTY_ID PropertyId, DWORD PropertyValueBufferSize, EVT_VARIANT* PropertyValueBuffer, DWORD* PropertyValueBufferUsed)
#uselib "wevtapi.dll"
#cfunc global EvtGetEventInfo "EvtGetEventInfo" intptr, int, int, var, var
; res = EvtGetEventInfo(Event, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
; Event : EVT_HANDLE -> "intptr"
; PropertyId : EVT_EVENT_PROPERTY_ID -> "int"
; PropertyValueBufferSize : DWORD -> "int"
; PropertyValueBuffer : EVT_VARIANT* optional, out -> "var"
; PropertyValueBufferUsed : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wevtapi = windows.NewLazySystemDLL("wevtapi.dll")
	procEvtGetEventInfo = wevtapi.NewProc("EvtGetEventInfo")
)

// Event (EVT_HANDLE), PropertyId (EVT_EVENT_PROPERTY_ID), PropertyValueBufferSize (DWORD), PropertyValueBuffer (EVT_VARIANT* optional, out), PropertyValueBufferUsed (DWORD* out)
r1, _, err := procEvtGetEventInfo.Call(
	uintptr(Event),
	uintptr(PropertyId),
	uintptr(PropertyValueBufferSize),
	uintptr(PropertyValueBuffer),
	uintptr(PropertyValueBufferUsed),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function EvtGetEventInfo(
  Event: NativeInt;   // EVT_HANDLE
  PropertyId: Integer;   // EVT_EVENT_PROPERTY_ID
  PropertyValueBufferSize: DWORD;   // DWORD
  PropertyValueBuffer: Pointer;   // EVT_VARIANT* optional, out
  PropertyValueBufferUsed: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'wevtapi.dll' name 'EvtGetEventInfo';
result := DllCall("wevtapi\EvtGetEventInfo"
    , "Ptr", Event   ; EVT_HANDLE
    , "Int", PropertyId   ; EVT_EVENT_PROPERTY_ID
    , "UInt", PropertyValueBufferSize   ; DWORD
    , "Ptr", PropertyValueBuffer   ; EVT_VARIANT* optional, out
    , "Ptr", PropertyValueBufferUsed   ; DWORD* out
    , "Int")   ; return: BOOL
●EvtGetEventInfo(Event, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed) = DLL("wevtapi.dll", "bool EvtGetEventInfo(int, int, dword, void*, void*)")
# 呼び出し: EvtGetEventInfo(Event, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
# Event : EVT_HANDLE -> "int"
# PropertyId : EVT_EVENT_PROPERTY_ID -> "int"
# PropertyValueBufferSize : DWORD -> "dword"
# PropertyValueBuffer : EVT_VARIANT* optional, out -> "void*"
# PropertyValueBufferUsed : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。