ホーム › System.EventLog › GetNumberOfEventLogRecords
GetNumberOfEventLogRecords
関数イベントログのレコード総数を取得する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL GetNumberOfEventLogRecords(
HANDLE hEventLog,
DWORD* NumberOfRecords
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hEventLog | HANDLE | in |
| NumberOfRecords | DWORD* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL GetNumberOfEventLogRecords(
HANDLE hEventLog,
DWORD* NumberOfRecords
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetNumberOfEventLogRecords(
IntPtr hEventLog, // HANDLE
out uint NumberOfRecords // DWORD* out
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetNumberOfEventLogRecords(
hEventLog As IntPtr, ' HANDLE
<Out> ByRef NumberOfRecords As UInteger ' DWORD* out
) As Boolean
End Function' hEventLog : HANDLE
' NumberOfRecords : DWORD* out
Declare PtrSafe Function GetNumberOfEventLogRecords Lib "advapi32" ( _
ByVal hEventLog As LongPtr, _
ByRef NumberOfRecords As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetNumberOfEventLogRecords = ctypes.windll.advapi32.GetNumberOfEventLogRecords
GetNumberOfEventLogRecords.restype = wintypes.BOOL
GetNumberOfEventLogRecords.argtypes = [
wintypes.HANDLE, # hEventLog : HANDLE
ctypes.POINTER(wintypes.DWORD), # NumberOfRecords : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
GetNumberOfEventLogRecords = Fiddle::Function.new(
lib['GetNumberOfEventLogRecords'],
[
Fiddle::TYPE_VOIDP, # hEventLog : HANDLE
Fiddle::TYPE_VOIDP, # NumberOfRecords : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn GetNumberOfEventLogRecords(
hEventLog: *mut core::ffi::c_void, // HANDLE
NumberOfRecords: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true)]
public static extern bool GetNumberOfEventLogRecords(IntPtr hEventLog, out uint NumberOfRecords);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_GetNumberOfEventLogRecords' -Namespace Win32 -PassThru
# $api::GetNumberOfEventLogRecords(hEventLog, NumberOfRecords)#uselib "ADVAPI32.dll"
#func global GetNumberOfEventLogRecords "GetNumberOfEventLogRecords" sptr, sptr
; GetNumberOfEventLogRecords hEventLog, varptr(NumberOfRecords) ; 戻り値は stat
; hEventLog : HANDLE -> "sptr"
; NumberOfRecords : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global GetNumberOfEventLogRecords "GetNumberOfEventLogRecords" sptr, var ; res = GetNumberOfEventLogRecords(hEventLog, NumberOfRecords) ; hEventLog : HANDLE -> "sptr" ; NumberOfRecords : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global GetNumberOfEventLogRecords "GetNumberOfEventLogRecords" sptr, sptr ; res = GetNumberOfEventLogRecords(hEventLog, varptr(NumberOfRecords)) ; hEventLog : HANDLE -> "sptr" ; NumberOfRecords : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetNumberOfEventLogRecords(HANDLE hEventLog, DWORD* NumberOfRecords) #uselib "ADVAPI32.dll" #cfunc global GetNumberOfEventLogRecords "GetNumberOfEventLogRecords" intptr, var ; res = GetNumberOfEventLogRecords(hEventLog, NumberOfRecords) ; hEventLog : HANDLE -> "intptr" ; NumberOfRecords : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetNumberOfEventLogRecords(HANDLE hEventLog, DWORD* NumberOfRecords) #uselib "ADVAPI32.dll" #cfunc global GetNumberOfEventLogRecords "GetNumberOfEventLogRecords" intptr, intptr ; res = GetNumberOfEventLogRecords(hEventLog, varptr(NumberOfRecords)) ; hEventLog : HANDLE -> "intptr" ; NumberOfRecords : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procGetNumberOfEventLogRecords = advapi32.NewProc("GetNumberOfEventLogRecords")
)
// hEventLog (HANDLE), NumberOfRecords (DWORD* out)
r1, _, err := procGetNumberOfEventLogRecords.Call(
uintptr(hEventLog),
uintptr(NumberOfRecords),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetNumberOfEventLogRecords(
hEventLog: THandle; // HANDLE
NumberOfRecords: Pointer // DWORD* out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'GetNumberOfEventLogRecords';result := DllCall("ADVAPI32\GetNumberOfEventLogRecords"
, "Ptr", hEventLog ; HANDLE
, "Ptr", NumberOfRecords ; DWORD* out
, "Int") ; return: BOOL●GetNumberOfEventLogRecords(hEventLog, NumberOfRecords) = DLL("ADVAPI32.dll", "bool GetNumberOfEventLogRecords(void*, void*)")
# 呼び出し: GetNumberOfEventLogRecords(hEventLog, NumberOfRecords)
# hEventLog : HANDLE -> "void*"
# NumberOfRecords : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。