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:
- The wrong diskette is in the drive. Insert %2 (Volume Serial Number: %3) into drive %1.
- The operating system cannot run %1.
- This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
- The image file %1 is signed, unable to modify.
- The system cannot find message text for message number 0x%1 in the message file for %2.
- ... and so on.