Solved

API: Report an event > description?

Posted on 1998-06-04
5
345 Views
Last Modified: 2013-12-03
To report an event in the event viewer, I use the ReportEvent function in the advapi32.dll from VB5. Everything looks fine (Source, ...) except the description of this event where I get: "The description for Event ID ( 1 ) in Source ( MY APP ) could not be found". I know that I have to use a resource file with the EventId and the string to display, but I don't know how to create it (I made one in VC++, and incorporated in my VB project unsuccessfully). So, the question is: how to create this resource file, how to compile it, and how to set it up in my project?
0
Comment
Question by:SergeD
[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
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1406848
Write a message text file (.MC file) and use the Message Compiler (MC.EXE) to convert it into a binary file (.BIN file) suitable for inclusion in a resource script (.RC file). Then build it into a DLL. The Message Compiler (MC.EXE) comes with a help file MC.HLP.
0
 

Author Comment

by:SergeD
ID: 1406849
I was expecting more details, like:
- an exemple of a MC file (it's not obvious, even with the help)
- how to create a dll from the rc file. Do I really need that from a VB project?

Thanx anyway.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1406850
>an exemple of a MC file (it's not obvious, even with the help)

Search the samples directory for *.mc files in the Windows Platform SDK (Win32 SDK). There are a lot.


>how to create a dll from the rc file. Do I really need that from a VB project?

I don't know how to do it with VB. For Visual C++, see Visual C++ Programmer's Guide documentation "Create a Resource-Only DLL".
0
 

Author Comment

by:SergeD
ID: 1406851
Ok, I've got it.
I made my MC file:

SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
               Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
               Warning=0x2:STATUS_SEVERITY_WARNING
               Error=0x3:STATUS_SEVERITY_ERROR
              )

MessageId=0x1001
Severity=Error
SymbolicName=MY_MSG
Language=English
Message displayed by my application:
.

I used MC.EXE and RC.EXE, and I have a .RES file. I can include this resource in a VB project, but when I call ReportLog, I got an event in the event viewer, but I still have this description: "The description for Event ID ( 1001 ) in Source ( MY APPLICATION ) could not be found.". Because, in fact I don't define an event identifier. I only have a message identifier (1001). So, how to link the message to the event?

Thanx for your help.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1406852
MC.EXE generates a .h file containing all the Event IDs. Use the symbols defined in this file.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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