Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: posting message to event log and clearing the extra content.



Permlink Replies: 5 - Last Post: Aug 31, 2015 4:08 PM Last Post By: Remy Lebeau (Te...
al nickels

Posts: 173
Registered: 7/16/09
posting message to event log and clearing the extra content.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 28, 2015 8:31 AM
I am writing event information to the event log with Delphi 6 and see the following information in the event log. I know that this can be cleared up. It appears that the message compiler from Microsoft (MC.exe) has to be used with a message file and somehow it integrates into my Delphi application, but the actual details of what to do next become murky as the example is for a service application. I do not have a service application. There is also some talk about a Delphi message compiler. Can someone please provide proper and clear direction on how to make the event log produce the clear information.

The description for Event ID in source can not be found. The local computer may not have the necessary registry information....

Edited by: al nickels on Aug 28, 2015 8:32 AM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: posting message to event log and clearing the extra content. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 29, 2015 1:04 AM   in response to: al nickels in response to: al nickels
al wrote:

I am writing event information to the event log with Delphi 6 and see
the following information in the event log. I know that this can be
cleared up.

Yes, it can, but it involves several steps.

You need to create a message table for your app, either in the app's resources
or in a separate DLL, where the table contains the desired category IDs and
event IDs, with associated text, and you need to register the location of
your message table in the EventLog Viewer's registry key:

Event Sources
https://msdn.microsoft.com/en-us/library/windows/desktop/aa363661.aspx

Adding an Event Source to the Registry
https://msdn.microsoft.com/en-us/library/aa363634.aspx

When you log an event message, you need to use RegisterEventSource() to access
your registered event source, and ReportEvent() specifying the desired category
and event IDs inside your message table.

It appears that the message compiler from Microsoft (MC.exe) has to
be used with a message file

That is how Microsoft prefers it be done, but it is not the only way. You
can create the revelent resource in a .RC/.RES file and link it your app/dll,
without using MC.EXE at all. I have done exactly that in my own BCB6-written
services and it works just fine.

and somehow it integrates into my Delphi application, but the actual details
of what to do next become murky as the example is for a service application.

I have posted the exact details several times before, such as this one:

TEventLogger registration
https://forums.embarcadero.com/thread.jspa?threadID=107659#666551

I do not have a service application.

That is not a requirement. Non-service apps can post messages to the system
EventLog. The only requirement is that the location of your app's message
table is registered so the EventLog Viewer can find it, and the logged category/event
IDs match the IDs in your message table.

There is also some talk about a Delphi message compiler.

There is no such compiler, certainly not related to the system EventLog anyway.

--
Remy Lebeau (TeamB)
al nickels

Posts: 173
Registered: 7/16/09
Re: posting message to event log and clearing the extra content. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 31, 2015 11:17 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
al wrote:

I am writing event information to the event log with Delphi 6 and see
the following information in the event log. I know that this can be
cleared up.

Yes, it can, but it involves several steps.

You need to create a message table for your app, either in the app's resources
or in a separate DLL, where the table contains the desired category IDs and
event IDs, with associated text, and you need to register the location of
your message table in the EventLog Viewer's registry key:
Stop - The information gets mangle a bit when reading online (trying to save paper)
I now really understand that there is more than one application involved. One is the application that logs the message, and the other is a .dll, .res, or a program compiled with the microsoft message compiler MC.EXE.
This application is passed to the RegisterEventSource() API call, that returns a handle, prior to logging the message.

Can you please provide more information on building the resource, or the .dll. What does the dll internal look like, or a sample res file. I can't thank you enough for all of the help that you provide.


--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: posting message to event log and clearing the extra content. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 31, 2015 11:29 AM   in response to: al nickels in response to: al nickels
al wrote:

Can you please provide more information on building the resource,
or the .dll. What does the dll internal look like, or a sample res file.

I already did. Did you see the link in my previous reply? It points to
an earlier discussion where I described, in detail, how I created an EventLog
message table in my own app without using MC.EXE. Here is the link again:

TEventLogger registration
https://forums.embarcadero.com/thread.jspa?threadID=107659#666551

--
Remy Lebeau (TeamB)
al nickels

Posts: 173
Registered: 7/16/09
Re: posting message to event log and clearing the extra content. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 31, 2015 3:44 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Nevermind. I did read your referenced link. I do not use cpp, Although you mention the XN resource editor it is in conjunction with your cpp output file. That make my delphi use with the resource not valid. No sample of a dll., its structure, or content. I can look from here and scour the internet for examples of either. Thanks for your help.

Remy Lebeau (TeamB) wrote:
al wrote:

Can you please provide more information on building the resource,
or the .dll. What does the dll internal look like, or a sample res file.

I already did. Did you see the link in my previous reply? It points to
an earlier discussion where I described, in detail, how I created an EventLog
message table in my own app without using MC.EXE. Here is the link again:

TEventLogger registration
https://forums.embarcadero.com/thread.jspa?threadID=107659#666551

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: posting message to event log and clearing the extra content. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 31, 2015 4:08 PM   in response to: al nickels in response to: al nickels
al wrote:

Nevermind. I did read your referenced link. I do not use cpp,
Although you mention the XN resource editor it is in conjunction
with your cpp output file.

Only because that is the resource editor I had on hand at the time. Any
resource editor that supports MESSAGETABLE resources will work, though.

That make my delphi use with the resource not valid.

All you have to do is create a .RES file containing a MESSAGETABLE resource,
whether you create it by compiling a .RC file, or by using a resource editor.
And then you can link the .RES file into your EXE/DLL. The end result is
the same.

No sample of a dll., its structure, or content.

Compiling a MESSAGETABLE into a DLL is no different than compiling it into
an EXE.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02