App.Logevent writes to a log of applicatipon, not to system log.
You need api to write there:
RegisterEventSource, ReportEvent, CopyMemory, GlobalAlloc...
Luckily someone already did the job:
download sources here http://www.montgomerysoftware.com/default.asp?PageID=72
(I did not test, but it seems a good one)
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
hi..
thanks for the code.. when i use this code to write the message (Message is : "Simple Error Message") Event log..
along with my message, some more text is added up saying.. "the Event ID not registed" ... from some website it is specified that, we need to register the Event ID detail in the Registry..
plz help me in resolving this problem..
thanks in adv..
the below message is the ectract from the EventLog
Code:
The description for Event ID ( 2 ) in Source ( Project1 ) cannot be found.
The local computer may not have the necessary registry information or
message DLL files to display messages from a remote computer.
The following information is part of the event: Simple Error Message.
Last edited by bharadwajrv; October 7th, 2003 at 03:50 AM.
...But I never wrote a message file, and do believe you cannot "include" it n Vb software like C developers can do...
Attached: the dll source modified to write to registry.
Be warned - the values are probably not correct, as I entered the exe app title (and not the dll one), and the file it try to point is not existing. Moreover, I am not sure the key (path inside registry) is correct:
I made a search and found something under a key named
SYSTEM\ControlSet001\Services\Eventlog\Application
of local machine. Do not know if it is the same that is claimed by author of web page you pointed in your previous message ...
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Option Explicit
'Be aware though, these functions will only work in the compiled EXE. They
'will be ignored in design mode. Check out the Microsoft knowledge base
'article Q161306 for more information.
Private Sub CmdLog_Click()
'-- Start Event Logging
Call App.StartLogging("", vbLogToNT)
'-- Log Events to NT
Call App.LogEvent("Info: Hello world!", vbLogEventTypeInformation)
Call App.LogEvent("Error: Goodbye, world!", vbLogEventTypeError)
Call App.LogEvent("Warning: welcome world!", vbLogEventTypeWarning)
End Sub
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.