Discussion:
clarification on formatmessage API
(too old to reply)
Ramakrishnan Kannan
21 years ago
Permalink
We generated a library called message.dll which exposes an export function by
name logmessage. for logmessage there are two parameters. one is message id
and other is a variable argument list. logmessage writes a message string
into a logfile. The message string is generated using FormatMessage api by
picking up a message definition from a message table resource in a already
loaded module using the message id and the variable argument list that were
passed to the logmessage interface. Currently the number of parameters in the
variable argument list is three. This library is now used by many programs
inside our product and also by external customers.

One of the customer is coming out with a requirement requesting to pass five
parameters instead of three parameters for the same message id.

Is it ok to modify the message table in the resource dll to accept five
parameters. In formatmessage for five parameters escape sequence, some
program will pass only three arguments in the va_list and some will pass all
the five. i.e there may be times where for the following message definition

"The message resource file name is %1%s \n The message identifier is: %2%d
.- The message number is: %3%d The function name is %4%s The parameters for
functions are %5%d"

there will be only three arguments in the variable argument list. Will this
lead to any problem? I am not able to find out in the document.

Without modifying the message id on the resource table i have to support
additional parameters in the FormatMessage api. Some may pass less in the
va_list and some will pass exact number of arguments. Can someone please
suggest some other mechanism?
Tony Proctor
21 years ago
Permalink
From the MSDN description of FormatMessage: "Each insert must have a
corresponding element in the array".

If there are insufficient elements in the argument array, or they're of an
inappapropriate type, then your application may crash with an Access
Violation

Tony Proctor
...
Loading...