ホーム › NetworkManagement.NetManagement › LogEventW
LogEventW
関数指定種別のイベントをイベントログに記録する(Unicode版)。
シグネチャ
// rtutils.dll (Unicode / -W)
#include <windows.h>
void LogEventW(
DWORD wEventType,
DWORD dwMessageId,
DWORD cNumberOfSubStrings,
LPWSTR* plpwsSubStrings
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| wEventType | DWORD | in |
| dwMessageId | DWORD | in |
| cNumberOfSubStrings | DWORD | in |
| plpwsSubStrings | LPWSTR* | in |
戻り値の型: void
各言語での呼び出し定義
// rtutils.dll (Unicode / -W)
#include <windows.h>
void LogEventW(
DWORD wEventType,
DWORD dwMessageId,
DWORD cNumberOfSubStrings,
LPWSTR* plpwsSubStrings
);[DllImport("rtutils.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern void LogEventW(
uint wEventType, // DWORD
uint dwMessageId, // DWORD
uint cNumberOfSubStrings, // DWORD
IntPtr plpwsSubStrings // LPWSTR*
);<DllImport("rtutils.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Sub LogEventW(
wEventType As UInteger, ' DWORD
dwMessageId As UInteger, ' DWORD
cNumberOfSubStrings As UInteger, ' DWORD
plpwsSubStrings As IntPtr ' LPWSTR*
)
End Sub' wEventType : DWORD
' dwMessageId : DWORD
' cNumberOfSubStrings : DWORD
' plpwsSubStrings : LPWSTR*
Declare PtrSafe Sub LogEventW Lib "rtutils" ( _
ByVal wEventType As Long, _
ByVal dwMessageId As Long, _
ByVal cNumberOfSubStrings As Long, _
ByVal plpwsSubStrings As LongPtr)
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LogEventW = ctypes.windll.rtutils.LogEventW
LogEventW.restype = None
LogEventW.argtypes = [
wintypes.DWORD, # wEventType : DWORD
wintypes.DWORD, # dwMessageId : DWORD
wintypes.DWORD, # cNumberOfSubStrings : DWORD
ctypes.c_void_p, # plpwsSubStrings : LPWSTR*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('rtutils.dll')
LogEventW = Fiddle::Function.new(
lib['LogEventW'],
[
-Fiddle::TYPE_INT, # wEventType : DWORD
-Fiddle::TYPE_INT, # dwMessageId : DWORD
-Fiddle::TYPE_INT, # cNumberOfSubStrings : DWORD
Fiddle::TYPE_VOIDP, # plpwsSubStrings : LPWSTR*
],
Fiddle::TYPE_VOID)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "rtutils")]
extern "system" {
fn LogEventW(
wEventType: u32, // DWORD
dwMessageId: u32, // DWORD
cNumberOfSubStrings: u32, // DWORD
plpwsSubStrings: *mut *mut u16 // LPWSTR*
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("rtutils.dll", CharSet = CharSet.Unicode)]
public static extern void LogEventW(uint wEventType, uint dwMessageId, uint cNumberOfSubStrings, IntPtr plpwsSubStrings);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtutils_LogEventW' -Namespace Win32 -PassThru
# $api::LogEventW(wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings)#uselib "rtutils.dll"
#func global LogEventW "LogEventW" wptr, wptr, wptr, wptr
; LogEventW wEventType, dwMessageId, cNumberOfSubStrings, varptr(plpwsSubStrings)
; wEventType : DWORD -> "wptr"
; dwMessageId : DWORD -> "wptr"
; cNumberOfSubStrings : DWORD -> "wptr"
; plpwsSubStrings : LPWSTR* -> "wptr"出力引数:
#uselib "rtutils.dll" #func global LogEventW "LogEventW" int, int, int, var ; LogEventW wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings ; wEventType : DWORD -> "int" ; dwMessageId : DWORD -> "int" ; cNumberOfSubStrings : DWORD -> "int" ; plpwsSubStrings : LPWSTR* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "rtutils.dll" #func global LogEventW "LogEventW" int, int, int, sptr ; LogEventW wEventType, dwMessageId, cNumberOfSubStrings, varptr(plpwsSubStrings) ; wEventType : DWORD -> "int" ; dwMessageId : DWORD -> "int" ; cNumberOfSubStrings : DWORD -> "int" ; plpwsSubStrings : LPWSTR* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void LogEventW(DWORD wEventType, DWORD dwMessageId, DWORD cNumberOfSubStrings, LPWSTR* plpwsSubStrings) #uselib "rtutils.dll" #func global LogEventW "LogEventW" int, int, int, var ; LogEventW wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings ; wEventType : DWORD -> "int" ; dwMessageId : DWORD -> "int" ; cNumberOfSubStrings : DWORD -> "int" ; plpwsSubStrings : LPWSTR* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void LogEventW(DWORD wEventType, DWORD dwMessageId, DWORD cNumberOfSubStrings, LPWSTR* plpwsSubStrings) #uselib "rtutils.dll" #func global LogEventW "LogEventW" int, int, int, intptr ; LogEventW wEventType, dwMessageId, cNumberOfSubStrings, varptr(plpwsSubStrings) ; wEventType : DWORD -> "int" ; dwMessageId : DWORD -> "int" ; cNumberOfSubStrings : DWORD -> "int" ; plpwsSubStrings : LPWSTR* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rtutils = windows.NewLazySystemDLL("rtutils.dll")
procLogEventW = rtutils.NewProc("LogEventW")
)
// wEventType (DWORD), dwMessageId (DWORD), cNumberOfSubStrings (DWORD), plpwsSubStrings (LPWSTR*)
r1, _, err := procLogEventW.Call(
uintptr(wEventType),
uintptr(dwMessageId),
uintptr(cNumberOfSubStrings),
uintptr(plpwsSubStrings),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure LogEventW(
wEventType: DWORD; // DWORD
dwMessageId: DWORD; // DWORD
cNumberOfSubStrings: DWORD; // DWORD
plpwsSubStrings: PPWideChar // LPWSTR*
); stdcall;
external 'rtutils.dll' name 'LogEventW';result := DllCall("rtutils\LogEventW"
, "UInt", wEventType ; DWORD
, "UInt", dwMessageId ; DWORD
, "UInt", cNumberOfSubStrings ; DWORD
, "Ptr", plpwsSubStrings ; LPWSTR*
, "Int") ; return: void●LogEventW(wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings) = DLL("rtutils.dll", "int LogEventW(dword, dword, dword, void*)")
# 呼び出し: LogEventW(wEventType, dwMessageId, cNumberOfSubStrings, plpwsSubStrings)
# wEventType : DWORD -> "dword"
# dwMessageId : DWORD -> "dword"
# cNumberOfSubStrings : DWORD -> "dword"
# plpwsSubStrings : LPWSTR* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。