Solved

EventLog handling

Posted on 2000-05-08
2
495 Views
Last Modified: 2013-12-03
Hey pals,

I'm trying to send some pretty simple messages to Event log file on NT 4.
Well, I tried just to use insertion strings parameter at ReportEvent
function but my boss got scared with "Description could not be found" messages. So I have no choice but to
create MC file.

Something went wrong with that - I performed all steps as written at MSDN
but no effect.
I understand there could be billions of reasons why it doesn't work, therefore I wonder if anyone could send me a simple example that would include : mc file, cpp file with ReportEvent function
call and step-by-step instructions how could I make dll from mc file.

Thanks in advance
0
Comment
Question by:schild
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 200 total points
ID: 2790409
NOTE:

You have to create your own key under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\

In my case (see event.reg below), the source name is EventSourceName("Event test").

EventMessageFile must point to your dll or exe file that contains the messages.

You may double-click on event.reg to write values into the registry, but you should modify the path to your program before.


;//------------------------------
;// EVENT.MC
;//------------------------------

MessageId=1000 SymbolicName=EVENT_HELLO
Language=English
Hello from the %1.
..

MessageId= SymbolicName=EVENT_BYE
Language=English
Bye from the %1.
..


//-------------------------------------
// EVENT.CPP
//-------------------------------------

#include <windows.h>
#include <iostream.h>
#include "event.h"

HANDLE  hEventLog=0;
LPCTSTR EventSourceName=TEXT("Event test");

void main(void)
{
   hEventLog=RegisterEventSource(NULL,EventSourceName);
   if(!hEventLog) {
      cout<<"Unable to register"<<endl;
      return;
   }

   LPCTSTR str[]={TEXT("TESTAPP")};
   ReportEvent(hEventLog,EVENTLOG_INFORMATION_TYPE,0,
      EVENT_HELLO,0,1,0,str,0);
   ReportEvent(hEventLog,EVENTLOG_ERROR_TYPE,0,
      EVENT_BYE,0,1,0,str,0);

   DeregisterEventSource(hEventLog);

}

rem ------------------------------------
rem MAKE.BAT
rem ------------------------------------
@echo off
mc event.mc
rc event.rc
cl event.cpp event.res advapi32.lib


-----------------------------------
event.reg
-----------------------------------

REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Event test]
"EventMessageFile"="D:\\TEMP\\EVENT\\EVENT.EXE"
"TypesSupported"=dword:00000007



0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2790417
There must be only the one dot after a message in the .MC file.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question