January 13th, 2012, 06:08 AM
Visual C++: [TIP] How to make a "Message DLL"?
Q: How to make a "Message DLL"?
Few more info
Windows system as well as many applications and libraries use message table resources (RT_MESSAGETABLE) in order to store message descriptions (error, warning, information, etc).
Further, FormatMessage can be called to retrieve the detailed description, given a message identifier/code returned by a WinAPI function call, GetLastError, taken from an event log, and so on.
Message table resources can be located in any type of binary file which can contain resources (exe, dll, ocx, etc).
If we want to store our own messages, a convenient place is a resource-only DLL. We can call it "Message DLL".
A: Here is how to make a "Message DLL", step by step (Visual Sudio 20xx):
- Make a new Win32 Project.
- In Win32 Application Wizard, check "DLL" and "Empty Project".
- Go to Project Property/Linker/Advanced and change No Entry Point property to "Yes(/NOENTRY)".
This is required to create a resource-only DLL.
- Add a message text file, let's say it "MyMessages.mc".
- Write a minimum of entries in .mc file, e.g. a message category.
; /* more entries go here */
- Go to Project Properties/Build Events/Pre-link Event and type the command for message compiler (MC.exe).
- Build the solution.
The message compiler generates a binary, a resource script, and a header file (e.g. MSG00001.bin, MyMessages.rc and MyMessages.h).
- In Solution Explorer window, right click on the project name and add MyMessages.rc and MyMessages.h.
- Further, complete the .mc file adding categries, messages and so on. The Message Text Files reference and examples can be found in MSDN (see the links below).
Last edited by ovidiucucu; January 13th, 2012 at 08:36 AM.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.