?
Solved

API: Report an event > description?

Posted on 1998-06-04
5
Medium Priority
?
349 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

770 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