Click to See Complete Forum and Search --> : NT Event Logging using Message Files


Ashutosh Khale
May 6th, 1999, 01:37 PM
I have a messsage file DLL containing message strings.I am trying to log the description associated with the symbolic names(codes) in my message file,into the application NT EventLog.

Using RegSetValueEx to register the message file under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\MYAPP


RegSetValueEx(hErrorMsgFileSubKey, _T("EventMessageFile"), 0, REG_EXPAND_SZ,
(LPBYTE)aryszBuf, ((_tcslen(aryszBuf) + 1) * sizeof(TCHAR))




To write to application NTEvent Log, I am using the ReportEvent function



ReportEvent(handleToEventSource,1,0,MYCODE_IN_MSGFILE, NULL, 0, 0, NULL, NULL);





ReportEvent function returns SUCCESS,however it is not able to pick the description for my error code MYCODE_IN_MSGFILE,and spits the following text in the event log...

"The description for Event ID ( 2 ) in Source ( MYAPP ) could not be found. It contains the following insertion string(s): ."

GetLastError gives error 203 ie.The system could not find the environment option that was entered. ERROR_ENVVAR_NOT_FOUND

I cannot figure out what it expects.Any leads would be appreciated.

Howard Birkett
May 6th, 1999, 02:42 PM
I assume you are using mc.exe to compile the messages

Howard

Ashutosh Khale
May 6th, 1999, 03:09 PM
Yes,i am using mc.exe
To build the message resource DLL(an MFC-Regular),i included the .h and .rc files generated using mc.exe.
Any leads?

Howard Birkett
May 7th, 1999, 01:12 PM
Its a while since I did this, but Ill see if I can look out the code on monday

Howard

July 1st, 1999, 12:00 AM
1. wirte a log.mc file and compile with mc , then generate log.h file where include the eventid your can reportevent in your app
2. use rc and link to build log.dll for NT event log
3. in your registry, add EventMessageFile item with value of the log.dll path
4. add log.h to your app project, and reportevent with eventid define in log.h
(Note: the eventid != messageid you define in log.mc)
That will be OK. I have make it out and work perfitly. Further information please contact zhuangyz@szonline.net