Write to Windows event log: Difference between revisions
Content added Content deleted
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: | Line 40: | ||
SendWinLogEvent(hSource, String="", evType=0x0004, evId=0x03EA, evCat=0, pData=0) { |
SendWinLogEvent(hSource, String="", evType=0x0004, evId=0x03EA, evCat=0, pData=0) { |
||
Ptr := A_PtrSize ? "Ptr" : "UInt" |
Ptr := A_PtrSize ? "Ptr" : "UInt" |
||
LPCtSTRs := A_PtrSize ? "Ptr*" : "UInt" |
|||
StringPut := A_IsUnicode ? "StrPut" : "StrPut2" |
StringPut := A_IsUnicode ? "StrPut" : "StrPut2" |
||
; Reserve and initialise space for the event message. |
; Reserve and initialise space for the event message. |
||
VarSetCapacity(eventMessage, StrLen(String), 0) |
VarSetCapacity(eventMessage, StrLen(String), 0) |
||
%StringPut%(String, eventMessage) |
%StringPut%(String, &eventMessage, A_IsUnicode ? "UTF-16" : "") |
||
r := DllCall("Advapi32.dll\ReportEvent" (A_IsUnicode ? "W" : "A") |
r := DllCall("Advapi32.dll\ReportEvent" (A_IsUnicode ? "W" : "A") |
||
, UInt, hSource ; handle |
, UInt, hSource ; handle |
||
Line 51: | Line 51: | ||
, UShort, evCat ; WORD, category |
, UShort, evCat ; WORD, category |
||
, UInt, evId ; DWORD, event ID, 0x03EA |
, UInt, evId ; DWORD, event ID, 0x03EA |
||
, Ptr, 0 |
, Ptr, 0 ; PSID, ptr to user security ID |
||
, UShort, 1 |
, UShort, 1 ; WORD, number of strings |
||
, UInt, VarSetCapacity(pData) |
, UInt, VarSetCapacity(pData) ; DWORD, data size |
||
, |
, LPCtSTRs, &eventMessage ; LPCTSTR*, ptr to a buffer ... |
||
, Ptr, (VarSetCapacity(pData)) ? &pData : 0 ) ; ptr to a buffer of binary data |
, Ptr, (VarSetCapacity(pData)) ? &pData : 0 ) ; ptr to a buffer of binary data |
||