I would like to present meaningful error messages when my program encounters Win32 errors. I call GetLastError
, and then FormatMessage
. But some of the error messages contain placeholders. For instance, ERROR_BAD_EXE_FORMAT
has the text:
%1 is not a valid Win32 application.
Presumably, the %1 is meant to be replaced by the name of the module which is not valid. How can I effect that replacement?
Note that I would ideally like a general solution because I note that there are many errors with placeholders. I can see the following messages in the documentation:
I think Raymond Chen effectively answers the question in a comment on his blog where he writes:
It bugs me too that system error messages contain
%1
insertions that you just have to "know" on a case-by-case basis.