ホーム › System.EventLog › EvtGetEventInfo
EvtGetEventInfo
関数イベントの情報プロパティを取得する。
シグネチャ
// wevtapi.dll
#include <windows.h>
BOOL EvtGetEventInfo(
EVT_HANDLE Event,
EVT_EVENT_PROPERTY_ID PropertyId,
DWORD PropertyValueBufferSize,
EVT_VARIANT* PropertyValueBuffer, // optional
DWORD* PropertyValueBufferUsed
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Event | EVT_HANDLE | in |
| PropertyId | EVT_EVENT_PROPERTY_ID | in |
| PropertyValueBufferSize | DWORD | in |
| PropertyValueBuffer | EVT_VARIANT* | outoptional |
| PropertyValueBufferUsed | DWORD* | 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 方式にも切替可。#uselib "wevtapi.dll" #cfunc global EvtGetEventInfo "EvtGetEventInfo" sptr, int, int, sptr, sptr ; res = EvtGetEventInfo(Event, PropertyId, PropertyValueBufferSize, varptr(PropertyValueBuffer), varptr(PropertyValueBufferUsed)) ; Event : EVT_HANDLE -> "sptr" ; PropertyId : EVT_EVENT_PROPERTY_ID -> "int" ; PropertyValueBufferSize : DWORD -> "int" ; PropertyValueBuffer : EVT_VARIANT* optional, out -> "sptr" ; PropertyValueBufferUsed : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, intptr ; res = EvtGetEventInfo(Event, PropertyId, PropertyValueBufferSize, varptr(PropertyValueBuffer), varptr(PropertyValueBufferUsed)) ; Event : EVT_HANDLE -> "intptr" ; PropertyId : EVT_EVENT_PROPERTY_ID -> "int" ; PropertyValueBufferSize : DWORD -> "int" ; PropertyValueBuffer : EVT_VARIANT* optional, out -> "intptr" ; PropertyValueBufferUsed : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。