Time for a chalenge - EventLog on windows Vista Ultimate
Posted: Mon Jan 05, 2009 8:30 pm
I'm working in a project which I intended to do in VB6. Didn't like much that dependencies from Net. Framework and decided to look for something better. Found PB. The project is going more or less OK with the help of this comunity. But... I need to write to windows EventLog and can't get a way to do it. My last atempt was to adapt a piece of code from MSDN even without knowing a thing about C++. Here is the result:
But it gives me an error 87: Invalid parameter
All the other examples arround the forum, do not write the message.
So the chalenge is... Can anyone get a snipet of code that enters an enter in the eventlog in windows vista?
Code: Select all
; ** Facility codes.
#FACILITY_SYSTEM = $0
#FACILITY_STUBS = $3
#FACILITY_RUNTIME = $2
#FACILITY_IO_ERROR_CODE = $4
; ** Severity codes.
#STATUS_SEVERITY_WARNING = $2
#STATUS_SEVERITY_SUCCESS = $0
#STATUS_SEVERITY_INFORMATIONAL = $1
#STATUS_SEVERITY_ERROR = $3
; ** Event Types
#EVENTLOG_SUCCESS = $0000 ; Information event
#EVENTLOG_AUDIT_FAILURE = $0010 ; Failure Audit event
#EVENTLOG_AUDIT_SUCCESS = $0008 ; Success Audit event
#EVENTLOG_ERROR_TYPE = $0001 ; Error event
#EVENTLOG_INFORMATION_TYPE = $0004 ; Information event
#EVENTLOG_WARNING_TYPE = $0002 ; Warning event
sourceName.s = "NetTax" ; The event source name.
dwEventID.w = 0 ; The event identifier.
cInserts.w = 1 ; The count of insert strings.
szMsg.s = "insertString" ; The insert strings.
evHdl = RegisterEventSource_(#Null, sourceName)
If evHdl = #Null
MessageRequester("", "Couldn't register event source")
EndIf
Result = ReportEvent_(evHdl, #EVENTLOG_SUCCESS, 0, dwEventID, #Null, cInserts, 0, @szMsg, #Null)
If Result = 0
MessageRequester("", "Couldn't report the event. Failed with error " + Str(GetLastError_()))
EndIf
DeregisterEventSource_(evHdl) All the other examples arround the forum, do not write the message.
So the chalenge is... Can anyone get a snipet of code that enters an enter in the eventlog in windows vista?