Anonymous user
Write to Windows event log: Difference between revisions
m
→{{header|AutoHotkey}}: Change to pointer type to allow the String parameter to appear in the Windows Event Viewer
Simple9371 (talk | contribs) m (→{{header|Batch File}}: Changed to the proper way to hide output (>NUL 2>&1)) |
m (→{{header|AutoHotkey}}: Change to pointer type to allow the String parameter to appear in the Windows Event Viewer) |
||
Line 40:
SendWinLogEvent(hSource, String="", evType=0x0004, evId=0x03EA, evCat=0, pData=0) {
Ptr := A_PtrSize ? "Ptr" : "UInt"
LPCtSTRs := A_PtrSize ? "Ptr*" : "UInt"
StringPut := A_IsUnicode ? "StrPut" : "StrPut2"
; Reserve and initialise space for the event message.
VarSetCapacity(eventMessage, StrLen(String), 0)
%StringPut%(String, &eventMessage, A_IsUnicode ? "UTF-16" : "")
r := DllCall("Advapi32.dll\ReportEvent" (A_IsUnicode ? "W" : "A")
, UInt, hSource ; handle
Line 51:
, UShort, evCat ; WORD, category
, UInt, evId ; DWORD, event ID, 0x03EA
, Ptr, 0
, UShort, 1
, UInt, VarSetCapacity(pData)
,
, Ptr, (VarSetCapacity(pData)) ? &pData : 0 ) ; ptr to a buffer of binary data
|