CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2001
    Posts
    4

    ReportEvent() grrrrr...

    Hello,
    I've been having problems getting ReportEvent() to work. The event log displays the text "The description for Event ID ( 6001 ) in Source ( MyApp ) cannot be found. [etc.]" before the text entered in ReportEvent(). I've tried using mc.exe to create a separate resource and linked it to the resource compiler adding the new resource and header (ResourceView>>ResourceIncludes...). I've also compiled the resource into a separate dll but this also doesnt work. What am i missing? Thanks in advance, Chris


  2. #2
    Join Date
    Apr 2000
    Location
    San Francisco, California, USA
    Posts
    4,467

    Re: ReportEvent() grrrrr...

    Is the message source properly registered? Could you reproduce the registration
    entries here?

    Russian Software Development Network -- http://www.rsdn.ru

  3. #3
    Join Date
    Jul 2001
    Posts
    4

    Re: ReportEvent() grrrrr...

    Hi Alex,
    Here is my code...

    hApplicationLog = RegisterEventSource(NULL, "MyApp");


    int result = ReportEvent( hApplicationLog,
    EVENTLOG_ERROR_TYPE,
    0, // category
    MSG_CANTCREATELOGFILE, // event id
    NULL, // user sid
    1, // number of strings
    0, // data size
    (LPCTSTR*)&error, // array o'strings
    NULL ); // data pointer




    In conjuction with the .mc reading
    FacilityNames=(MyApp=111)

    MessageId=6001
    Severity=Error
    SymbolicName=MSG_CANTCREATELOGFILE
    FacilityName=MyApp
    Language=English
    Could not create log file
    .

    I have also tried registering using OpenEventLog() and using the default setting "Facility=Application" in the *.mc file.
    Nothing seems to help! Thanks, Chris


  4. #4
    Join Date
    Apr 2000
    Location
    San Francisco, California, USA
    Posts
    4,467

    Re: ReportEvent() grrrrr...

    I meant you show the entries in the registry you made to
    register your event source.

    Russian Software Development Network -- http://www.rsdn.ru

  5. #5
    Join Date
    Jul 2001
    Posts
    4

    Re: ReportEvent() grrrrr...

    Sorry Alex, I misunderstood.
    I didn't know the registry was involved.
    The RegisterEventSource returns a valid handle, but there is no entry in the registry...
    When i do...


    hApplicationLog = RegisterEventSource(NULL, "UniqueString");




    and then do
    Registry Editor>>Edit>>Find..."UniqueString"
    the registry comes back with nothing.
    Thanks, Chris.



  6. #6
    Join Date
    Apr 2000
    Location
    San Francisco, California, USA
    Posts
    4,467

    Re: ReportEvent() grrrrr...

    In order the Event Viewer to find your DLL that contains a message resource,
    you should add some entries to the system registry. In the very simple case
    the following entries will be enough:

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\Application\your-name
    EventMessageFile[REG_SZ] = path to your DLL
    TypesSupported[REG_DWORD] = 7

    See event logging documentation on MSDN for more information:
    http://msdn.microsoft.com/library/en...ntlog_6jhv.asp

    See also the following knowledge base article:
    http://support.microsoft.com/support.../Q166/9/02.asp


    Russian Software Development Network -- http://www.rsdn.ru

  7. #7
    Join Date
    Jul 2001
    Posts
    4

    Re: ReportEvent() grrrrr...

    Thanks for your time Alex,
    I appreciate it.
    Chris.


  8. #8
    Join Date
    Dec 2015
    Posts
    3

    Re: ReportEvent() grrrrr...

    Quote Originally Posted by chris haddon View Post
    Hello,
    I've been having problems getting ReportEvent() to work. The event log displays the text "The description for Event ID ( 6001 ) in Source ( MyApp ) cannot be found. [etc.]" before the text entered in ReportEvent(). I've tried using mc.exe to create a separate resource and linked it to the resource compiler adding the new resource and header (ResourceView>>ResourceIncludes...). I've also compiled the resource into a separate dll but this also doesnt work. What am i missing? Thanks in advance, Chris
    This an old link, but I've got a legacy app I'm working with that generates the same errors.

    Basically I scrapped the NTService.LogEvent function and used the simple I found a simple code fix here:
    http://www.jameswiseman.com/blog/201...-event-logger/

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured