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

EvtGetLogInfo

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

シグネチャ

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

BOOL EvtGetLogInfo(
    EVT_HANDLE Log,
    EVT_LOG_PROPERTY_ID PropertyId,
    DWORD PropertyValueBufferSize,
    EVT_VARIANT* PropertyValueBuffer,   // optional
    DWORD* PropertyValueBufferUsed
);

パラメーター

名前方向
LogEVT_HANDLEin
PropertyIdEVT_LOG_PROPERTY_IDin
PropertyValueBufferSizeDWORDin
PropertyValueBufferEVT_VARIANT*outoptional
PropertyValueBufferUsedDWORD*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL EvtGetLogInfo(
    EVT_HANDLE Log,
    EVT_LOG_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 EvtGetLogInfo(
    IntPtr Log,   // EVT_HANDLE
    int PropertyId,   // EVT_LOG_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 EvtGetLogInfo(
    Log As IntPtr,   ' EVT_HANDLE
    PropertyId As Integer,   ' EVT_LOG_PROPERTY_ID
    PropertyValueBufferSize As UInteger,   ' DWORD
    PropertyValueBuffer As IntPtr,   ' EVT_VARIANT* optional, out
    <Out> ByRef PropertyValueBufferUsed As UInteger   ' DWORD* out
) As Boolean
End Function
' Log : EVT_HANDLE
' PropertyId : EVT_LOG_PROPERTY_ID
' PropertyValueBufferSize : DWORD
' PropertyValueBuffer : EVT_VARIANT* optional, out
' PropertyValueBufferUsed : DWORD* out
Declare PtrSafe Function EvtGetLogInfo Lib "wevtapi" ( _
    ByVal Log 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

EvtGetLogInfo = ctypes.windll.wevtapi.EvtGetLogInfo
EvtGetLogInfo.restype = wintypes.BOOL
EvtGetLogInfo.argtypes = [
    ctypes.c_ssize_t,  # Log : EVT_HANDLE
    ctypes.c_int,  # PropertyId : EVT_LOG_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')
EvtGetLogInfo = Fiddle::Function.new(
  lib['EvtGetLogInfo'],
  [
    Fiddle::TYPE_INTPTR_T,  # Log : EVT_HANDLE
    Fiddle::TYPE_INT,  # PropertyId : EVT_LOG_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 EvtGetLogInfo(
        Log: isize,  // EVT_HANDLE
        PropertyId: i32,  // EVT_LOG_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 EvtGetLogInfo(IntPtr Log, int PropertyId, uint PropertyValueBufferSize, IntPtr PropertyValueBuffer, out uint PropertyValueBufferUsed);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wevtapi_EvtGetLogInfo' -Namespace Win32 -PassThru
# $api::EvtGetLogInfo(Log, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
#uselib "wevtapi.dll"
#func global EvtGetLogInfo "EvtGetLogInfo" sptr, sptr, sptr, sptr, sptr
; EvtGetLogInfo Log, PropertyId, PropertyValueBufferSize, varptr(PropertyValueBuffer), varptr(PropertyValueBufferUsed)   ; 戻り値は stat
; Log : EVT_HANDLE -> "sptr"
; PropertyId : EVT_LOG_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 EvtGetLogInfo "EvtGetLogInfo" sptr, int, int, var, var
; res = EvtGetLogInfo(Log, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
; Log : EVT_HANDLE -> "sptr"
; PropertyId : EVT_LOG_PROPERTY_ID -> "int"
; PropertyValueBufferSize : DWORD -> "int"
; PropertyValueBuffer : EVT_VARIANT* optional, out -> "var"
; PropertyValueBufferUsed : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL EvtGetLogInfo(EVT_HANDLE Log, EVT_LOG_PROPERTY_ID PropertyId, DWORD PropertyValueBufferSize, EVT_VARIANT* PropertyValueBuffer, DWORD* PropertyValueBufferUsed)
#uselib "wevtapi.dll"
#cfunc global EvtGetLogInfo "EvtGetLogInfo" intptr, int, int, var, var
; res = EvtGetLogInfo(Log, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
; Log : EVT_HANDLE -> "intptr"
; PropertyId : EVT_LOG_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")
	procEvtGetLogInfo = wevtapi.NewProc("EvtGetLogInfo")
)

// Log (EVT_HANDLE), PropertyId (EVT_LOG_PROPERTY_ID), PropertyValueBufferSize (DWORD), PropertyValueBuffer (EVT_VARIANT* optional, out), PropertyValueBufferUsed (DWORD* out)
r1, _, err := procEvtGetLogInfo.Call(
	uintptr(Log),
	uintptr(PropertyId),
	uintptr(PropertyValueBufferSize),
	uintptr(PropertyValueBuffer),
	uintptr(PropertyValueBufferUsed),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function EvtGetLogInfo(
  Log: NativeInt;   // EVT_HANDLE
  PropertyId: Integer;   // EVT_LOG_PROPERTY_ID
  PropertyValueBufferSize: DWORD;   // DWORD
  PropertyValueBuffer: Pointer;   // EVT_VARIANT* optional, out
  PropertyValueBufferUsed: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'wevtapi.dll' name 'EvtGetLogInfo';
result := DllCall("wevtapi\EvtGetLogInfo"
    , "Ptr", Log   ; EVT_HANDLE
    , "Int", PropertyId   ; EVT_LOG_PROPERTY_ID
    , "UInt", PropertyValueBufferSize   ; DWORD
    , "Ptr", PropertyValueBuffer   ; EVT_VARIANT* optional, out
    , "Ptr", PropertyValueBufferUsed   ; DWORD* out
    , "Int")   ; return: BOOL
●EvtGetLogInfo(Log, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed) = DLL("wevtapi.dll", "bool EvtGetLogInfo(int, int, dword, void*, void*)")
# 呼び出し: EvtGetLogInfo(Log, PropertyId, PropertyValueBufferSize, PropertyValueBuffer, PropertyValueBufferUsed)
# Log : EVT_HANDLE -> "int"
# PropertyId : EVT_LOG_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)。