.MC file and Event Viewer: Placeholders for Categories?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: .MC file and Event Viewer: Placeholders for Categories?

  1. #1
    Join Date
    Aug 2009
    Posts
    10

    .MC file and Event Viewer: Placeholders for Categories?

    Hello,

    I am using MFC in order to throw events in a custom event log of the windows
    event viewer. I am using a .MC file where I store the Categories and the
    message definitions used for the events fired on the event viewer.

    .MC contains only one message definition since I use a placeholder (%1) in
    order to load the messages dynamically from my application.

    MessageIdTypedef=DWORD

    MessageId=+1
    Severity=Error
    SymbolicName=MSG_INFORMATION
    Language=English
    %1
    .

    I want to do the same with the Categories but I could not find how I can
    add a placeholder for them. So, now I use static messages in the Categories
    which are contained in .MC file.

    MessageId = +1
    SymbolicName = CATEGORY_ONE
    Severity = Success
    Language = English
    Category One
    .

    But I want to load strings dynamically from my application and not
    statically from the .MC file. Something like this for example:

    MessageId = +1
    SymbolicName = CATEGORY_ONE
    Severity = Success
    Language = English
    %1
    .

    How can I do it?

    Thank you in advance

  2. #2
    Join Date
    Aug 2009
    Posts
    10

    Re: .MC file and Event Viewer: Placeholders for Categories?

    Hello again,

    I just want to make myself a bit more clear:

    I use the ReportEvent function
    (http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx) in order
    to fire events in the Event Viewer.

    The 4th argument of the Report Event is:
    dwEventID [in] The event identifier.The event identifier specifies the entry
    in the message file associated with the event source.

    The 8th argument is:
    pStrings [in] A pointer to a buffer containing an array of null-terminated
    strings that are merged into the message before Event Viewer displays the
    string to the user.

    So, I use the function in that way:

    ReportEvent( hEventLog, //event log handler
    EVENTLOG_INFORMATION_TYPE, //event type
    CATEGORY_ONE, //SymbolicName of a category defined in .mc file
    MSG_INFORMATION, //SymbolicName of the message definition defined in .mc file
    userPSID, //current user's security identifier
    1, //Number of strings to be logged
    sizeData, //size of the binary data
    logStr,//message shown in the event description.It is the data placed on %1
    of the MSG_INFORMATION,
    (LPVOID) BinaryData) //binary data

    The logStr is provided by the application or by the application's .rc file,
    so there is the possibility that the
    app supplies the text to the event viewer. But does not this possibility
    exist for the event category as well?

    Thank you!

Tags for this Thread

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