EventLog and Win 2K
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: EventLog and Win 2K

  1. #1
    Join Date
    Dec 2001
    Location
    UK
    Posts
    308

    EventLog and Win 2K

    Hi,
    my application uses App.LogEvent to write to the OS Event log.. On Win 2K system.. it is not writing to the Event log..

    any idea, how to write to the event log

    thanks in adv..
    Venu
    Venu Bharadwaj
    "Dream it. U can do it!"

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726
    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.

  3. #3
    Join Date
    Dec 2001
    Location
    UK
    Posts
    308
    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.
    Venu Bharadwaj
    "Dream it. U can do it!"

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Modify registry is not really difficoult...

    ...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 ...
    Attached Files Attached Files
    ...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.

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    An easy solution...

    Found an easy one:
    http://groups.yahoo.com/group/vbsquare/message/28
    Code:
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center