How to Support Language-Independent Strings in Event Logging

Last reviewed: December 16, 1996
Article ID: Q125661
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.1, 3.5, 3.51, 4.0
    
    -------------------------------------------------------------------------

SUMMARY

Insertion strings in the event log entries are language-independent. Instead of using string literals as the insertion string, use "%%n" as the insertion string.

MORE INFORMATION

When the event viewer sees "%%n", it looks up the ParameterMessageFile value in the registry, under the source of the event, as in this example:

   HKEY_LOCAL_MACHINE\SYSTEM\
      CurrentControlSet\
      Services\
      EventLog\
      Security\
      ...

   -or-

   HKEY_LOCAL_MACHINE\SYSTEM\
      CurrentControlSet\
      Services\
      EventLog\
      System\
      Service Control Manager

It then calls the LoadLibrary() function of the ParameterMessageFile. Then it calls FormatMessage() using "n" as the ID.

For example, suppose an event log entry has the source "Service Control Manager" and the description is "Failed to start the service due to the following error: %%245."

In the registry, you find:

   HKEY_LOCAL_MACHINE\SYSTEM\
      CurrentControlSet\
      Services\
      EventLog\
      System\
      Service Control Manager
         EventMessageFile...
         ParameterMessageFile REG_SZ  kernel32.dll
         TypesSupported...
         ...

Therefore, you need to follow these steps:

  1. Use LoadLibrary() with KERNEL32.DLL.

  2. Call FormatMessage() using the module handle obtained in step 1 and a string ID of 245.

  3. Replace %%245 in the description with the string obtained in step 2.


Additional reference words: 3.10 3.50 3.51 4.00
KBCategory: kbprg
KBSubcategory: BseMisc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.