Solved

API: Report an event > description?

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…

828 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