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

Raymond Chen

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.

0 comments

Discussion is closed.

Feedback usabilla icon