Win32 API 日本語リファレンス
ホームNetworkManagement.NetManagement › LogEventA

LogEventA

関数
指定種別のイベントをイベントログに記録する(ANSI版)。
DLLrtutils.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// rtutils.dll  (ANSI / -A)
#include <windows.h>

void LogEventA(
    DWORD wEventType,
    DWORD dwMessageId,
    DWORD cNumberOfSubStrings,
    LPSTR* plpwsSubStrings
);

パラメーター

名前方向
wEventTypeDWORDin
dwMessageIdDWORDin
cNumberOfSubStringsDWORDin
plpwsSubStringsLPSTR*in

戻り値の型: void

各言語での呼び出し定義

// rtutils.dll  (ANSI / -A)
#include <windows.h>

void LogEventA(
    DWORD wEventType,
    DWORD dwMessageId,
    DWORD cNumberOfSubStrings,
    LPSTR* plpwsSubStrings
);
[DllImport("rtutils.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern void LogEventA(
    uint wEventType,   // DWORD
    uint dwMessageId,   // DWORD
    uint cNumberOfSubStrings,   // DWORD
    IntPtr plpwsSubStrings   // LPSTR*
);
<DllImport("rtutils.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Sub LogEventA(
    wEventType As UInteger,   ' DWORD
    dwMessageId As UInteger,   ' DWORD
    cNumberOfSubStrings As UInteger,   ' DWORD
    plpwsSubStrings As IntPtr   ' LPSTR*
)
End Sub
' wEventType : DWORD
' dwMessageId : DWORD
' cNumberOfSubStrings : DWORD
' plpwsSubStrings : LPSTR*
Declare PtrSafe Sub LogEventA Lib "rtutils" ( _
    ByVal wEventType As Long, _
    ByVal dwMessageId As Long, _
    ByVal cNumberOfSubStrings As Long, _
    ByVal plpwsSubStrings As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

LogEventA = ctypes.windll.rtutils.LogEventA
LogEventA.restype = None
LogEventA.argtypes = [
    wintypes.DWORD,  # wEventType : DWORD
    wintypes.DWORD,  # dwMessageId : DWORD
    wintypes.DWORD,  # cNumberOfSubStrings : DWORD
    ctypes.c_void_p,  # plpwsSubStrings : LPSTR*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('rtutils.dll')
LogEventA = Fiddle::Function.new(
  lib['LogEventA'],
  [
    -Fiddle::TYPE_INT,  # wEventType : DWORD
    -Fiddle::TYPE_INT,  # dwMessageId : DWORD
    -Fiddle::TYPE_INT,  # cNumberOfSubStrings : DWORD
    Fiddle::TYPE_VOIDP,  # plpwsSubStrings : LPSTR*
  ],
  Fiddle::TYPE_VOID)
#[link(name = "rtutils")]
extern "system" {
    fn LogEventA(
        wEventType: u32,  // DWORD
        dwMessageId: u32,  // DWORD
        cNumberOfSubStrings: u32,  // DWORD
        plpwsSubStrings: *mut *mut u8  // LPSTR*
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("rtutils.dll", CharSet = CharSet.Ansi)]
public static extern void LogEventA(uint wEventType, uint dwMessageId, uint cNumberOfSubStrings, IntPtr plpwsSubStrings);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtutils_LogEventA' -Namespace Win32 -PassThru
# $api::LogEventA(wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings)
#uselib "rtutils.dll"
#func global LogEventA "LogEventA" sptr, sptr, sptr, sptr
; LogEventA wEventType, dwMessageId, cNumberOfSubStrings, varptr(plpwsSubStrings)
; wEventType : DWORD -> "sptr"
; dwMessageId : DWORD -> "sptr"
; cNumberOfSubStrings : DWORD -> "sptr"
; plpwsSubStrings : LPSTR* -> "sptr"
出力引数:
#uselib "rtutils.dll"
#func global LogEventA "LogEventA" int, int, int, var
; LogEventA wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings
; wEventType : DWORD -> "int"
; dwMessageId : DWORD -> "int"
; cNumberOfSubStrings : DWORD -> "int"
; plpwsSubStrings : LPSTR* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void LogEventA(DWORD wEventType, DWORD dwMessageId, DWORD cNumberOfSubStrings, LPSTR* plpwsSubStrings)
#uselib "rtutils.dll"
#func global LogEventA "LogEventA" int, int, int, var
; LogEventA wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings
; wEventType : DWORD -> "int"
; dwMessageId : DWORD -> "int"
; cNumberOfSubStrings : DWORD -> "int"
; plpwsSubStrings : LPSTR* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rtutils = windows.NewLazySystemDLL("rtutils.dll")
	procLogEventA = rtutils.NewProc("LogEventA")
)

// wEventType (DWORD), dwMessageId (DWORD), cNumberOfSubStrings (DWORD), plpwsSubStrings (LPSTR*)
r1, _, err := procLogEventA.Call(
	uintptr(wEventType),
	uintptr(dwMessageId),
	uintptr(cNumberOfSubStrings),
	uintptr(plpwsSubStrings),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure LogEventA(
  wEventType: DWORD;   // DWORD
  dwMessageId: DWORD;   // DWORD
  cNumberOfSubStrings: DWORD;   // DWORD
  plpwsSubStrings: PPAnsiChar   // LPSTR*
); stdcall;
  external 'rtutils.dll' name 'LogEventA';
result := DllCall("rtutils\LogEventA"
    , "UInt", wEventType   ; DWORD
    , "UInt", dwMessageId   ; DWORD
    , "UInt", cNumberOfSubStrings   ; DWORD
    , "Ptr", plpwsSubStrings   ; LPSTR*
    , "Int")   ; return: void
●LogEventA(wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings) = DLL("rtutils.dll", "int LogEventA(dword, dword, dword, void*)")
# 呼び出し: LogEventA(wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings)
# wEventType : DWORD -> "dword"
# dwMessageId : DWORD -> "dword"
# cNumberOfSubStrings : DWORD -> "dword"
# plpwsSubStrings : LPSTR* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。