Looking at writing code in C++ to place messages in the EVENTLOG. Found pieces, but nothing provide sequences. Looking for examples of placing the message.
This is a simple deal..First you must be sure what information you want to get written in Event Log...
I used it in past for the apps to log important events...
I mostly do it in COM/SDK/ATL ways...MFC is also same
Ok I am giving you a simple example
1.Open EventLog using API "OpenEventLog".
2.Mostly it is written for Application Log
3.Then as soon as your one task is done,Use "ReportEvent" to write your event in Application log
4.Then close it using "CloseEventLog"..
In SDK whole series of functions for event log is given..
Hope it helps..
cheers
There is a good example in MSDN under the title "Creating a Simple Win32 Service in C++" that uses Event Logging. Perhaps the most time consuming thing for me was getting the process straight to create a MESSAGETABLE entry for the resources and integrating it into my system. While I'm not certain if my way is the "correct" (or even recommended) method, I have found that it works.
My approach was to allow integration of a MESSAGETABLE into my resource file while allowing me to inherit the CNTService class into my own specific service. This required that I combine the CNTService .mc file with the one used by my new service into a single file prior to submitting it to the message compiler as part of a custom build step in the IDE. I then add the resultant files to the resource file via the "View/Resource Includes" menu in the C++ IDE. If you need more detail, let me know, but I would recommend looking at the MSDN examples first and study the way in which the resource file(s) are integrated into your project.
If someone knows a better way, I'm all ears. This method is a little cumbersome.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.