Solved

API: Report an event > description?

Posted on 1998-06-04
5
330 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
  • 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now