|
-
Sep 25th, 2001, 10:01 AM
#1
Thread Starter
Addicted Member
event log
can you use an api to write information to the event log?
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
-
Sep 25th, 2001, 12:04 PM
#2
I have some code that will allow you to read entries in the Event Log. You might be able to modify it so you can do a write.
If you want this code, let me know.
-
Sep 26th, 2001, 04:00 AM
#3
Thread Starter
Addicted Member
the code would be great, thanks
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
-
Sep 26th, 2001, 06:41 AM
#4
Here you go.
Public Declare Function RegisterEventSource Lib "advapi32.dll" Alias _
"RegisterEventSourceA" (ByVal lpUNCServerName As String, _
ByVal lpSourceName As String) As Long
Public Declare Function DeregisterEventSource Lib "advapi32.dll" ( _
ByVal hEventLog As Long) As Long
Public Declare Function ReportEvent Lib "advapi32.dll" Alias _
"ReportEventA" (ByVal hEventLog As Long, ByVal wType As Integer, _
ByVal wCategory As Integer, ByVal dwEventID As Long, _
ByVal lpUserSid As Any, ByVal wNumStrings As Integer, _
ByVal dwDataSize As Long, plpStrings As Long, _
lpRawData As Any) As Boolean
Public Declare Function GetLastError Lib "kernel32" () As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
hpvDest As Any, hpvSource As Any, _
ByVal cbCopy As Long)
Public Declare Function GlobalAlloc Lib "kernel32" ( _
ByVal wFlags As Long, _
ByVal dwBytes As Long) As Long
Public Declare Function GlobalFree Lib "kernel32" ( _
ByVal hMem As Long) As Long
Public Const EVENTLOG_SUCCESS = 0
Public Const EVENTLOG_ERROR_TYPE = 1
Public Const EVENTLOG_WARNING_TYPE = 2
Public Const EVENTLOG_INFORMATION_TYPE = 4
Public Const EVENTLOG_AUDIT_SUCCESS = 8
Public Const EVENTLOG_AUDIT_FAILURE = 10
Public Sub LogNTEvent(sString As String, iLogType As Integer, _
iEventID As Long)
Dim bRC As Boolean
Dim iNumStrings As Integer
Dim hEventLog As Long
Dim hMsgs As Long
Dim cbStringSize As Long
hEventLog = RegisterEventSource("", App.Title)
cbStringSize = Len(sString) + 1
hMsgs = GlobalAlloc(&H40, cbStringSize)
CopyMemory ByVal hMsgs, ByVal sString, cbStringSize
iNumStrings = 1
If ReportEvent(hEventLog, _
iLogType, 0, _
iEventID, 0&, _
iNumStrings, cbStringSize, _
hMsgs, hMsgs) = 0 Then
MsgBox GetLastError()
End If
Call GlobalFree(hMsgs)
DeregisterEventSource (hEventLog)
End Sub
Sub Main()
Call LogNTEvent("Information from " & App.EXEName, _
EVENTLOG_INFORMATION_TYPE, 1001)
Call LogNTEvent("Warning from " & App.EXEName, _
EVENTLOG_WARNING_TYPE, 1002)
Call LogNTEvent("Error from " & App.EXEName, _
EVENTLOG_ERROR_TYPE, 1003)
MsgBox "Done"
End Sub
-
Feb 5th, 2002, 10:23 AM
#5
If you have info on how to read the event log, specifically the description and user id of an event, I would much appreciate it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|