Visual C++: [TIP] How to make a "Message DLL"?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Visual C++: [TIP] How to make a "Message DLL"?

  1. #1
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,027

    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):
    1. Make a new Win32 Project.


      .
    2. In Win32 Application Wizard, check "DLL" and "Empty Project".


      .
    3. Go to Project Property/Linker/Advanced and change No Entry Point property to "Yes(/NOENTRY)".
      This is required to create a resource-only DLL.


      .
    4. Add a message text file, let's say it "MyMessages.mc".


      .
    5. Write a minimum of entries in .mc file, e.g. a message category.

      Code:
      MessageIdTypedef=WORD
      
      MessageId=0x1
      SymbolicName=CATEGORY_GENERAL
      Language=English
      General
      .
      ; /* more entries go here */
    6. Go to Project Properties/Build Events/Pre-link Event and type the command for message compiler (MC.exe).


      .
    7. 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).
    8. In Solution Explorer window, right click on the project name and add MyMessages.rc and MyMessages.h.


      .
    9. 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).


    Resources [MSDN]


    See also
    Last edited by ovidiucucu; January 13th, 2012 at 07:36 AM.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center