Solved

API: Report an event > description?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error email attachment VB2010 5 32
How to copy an image file into clipboard C/C++? 1 152
Need more details 5 124
Question to Pivot table 1 34
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

16 Experts available now in Live!

Get 1:1 Help Now