September 1st, 2008

How do I convert an error code to text when FORMAT_MESSAGE_FROM_SYSTEM doesn’t work?

For the same reason that not all error codes are defined in winerror.h, not all error strings are defined in the system message table. If you’ve ever played with the message compiler, you’d quickly have recognized the winerror.h file as the header file associated with a message resource. In other words, there’s a .mc file that gets processed by the message compiler, and out pops the message resource (which becomes the system message table) and the winerror.h header file.

As we saw a few years ago, not all error messages live in winerror.h, which means that not all error messages live in the system message table. Each component that provides error codes outside of winerror.h needs to provide its own message table. For example, messages for network errors can be found in netmsg.dll. Similarly, winhttp error message text can be found in winhttp.dll. I don’t know about other message ranges; hopefully the documentation for the component that generates those errors also mentions where you can find the text.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.