<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx</link><description>If you're not in control of the message.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6580836</link><pubDate>Wed, 28 Nov 2007 18:51:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6580836</guid><dc:creator>Anthony Wieser</dc:creator><description>
&lt;p&gt;I've always wondered who was in control of that string. &amp;nbsp;It certainly looks bad if a %1 gets back to the user.&lt;/p&gt;

&lt;p&gt;Is there any way to know what should be provided for a given error message, or is it deeply bound up with the implementation inside the system, and hence inpenetrable.&lt;/p&gt;

&lt;p&gt;The fact that you say "you had better pass the FORMAT_MESSAGE_IGNORE_INSERTS flag" implies there is no way to know what to pass, which is a shame.&lt;/p&gt;
&lt;div class="post"&gt;[&lt;i&gt;It bugs me too that system error messages contain %1 insertions that you just have to "know" on a case-by-case basis. -Raymond&lt;/i&gt;]&lt;/div&gt;</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6582691</link><pubDate>Wed, 28 Nov 2007 20:52:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6582691</guid><dc:creator>Tom</dc:creator><description>&lt;p&gt;Kind-of on topic: Do you know why Visual Studio does not allow you to insert a message resource from the Add Resource menu? &amp;nbsp;I know I can add custom build steps to get it done, but the fact the feature is not present always made me wonder if using message resources (as opposed to a string table or some other localized error message mechanism) was the proper way of handling error strings.&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6582779</link><pubDate>Wed, 28 Nov 2007 21:00:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6582779</guid><dc:creator>Matthew</dc:creator><description>&lt;p&gt;Damn, hadn't realized this.&lt;/p&gt;
&lt;p&gt;One guilty codebase now fixed -- thanks!&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6583029</link><pubDate>Wed, 28 Nov 2007 21:24:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6583029</guid><dc:creator>Anthony Wieser</dc:creator><description>&lt;p&gt;What worries me more Raymond, is that though it works today if I &amp;quot;know&amp;quot; what it does, there's not necessarily a contract that says it'll stay that way.&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6583388</link><pubDate>Wed, 28 Nov 2007 22:08:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6583388</guid><dc:creator>b</dc:creator><description>&lt;p&gt;Thanks for this article. &amp;nbsp;I had been misusing FormatMessage() not realizing that some system error codes had insertions.&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6583519</link><pubDate>Wed, 28 Nov 2007 22:20:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6583519</guid><dc:creator>meh</dc:creator><description>&lt;p&gt;Yes, definitely worth mentioning. Thanks, Raymond. I did suspect that something like this may happen, but I wasn't truly convinced. Fortunately I figured... better safe than sorry - and used both flags. Now we all know for sure.&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6585036</link><pubDate>Thu, 29 Nov 2007 00:16:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6585036</guid><dc:creator>Peter</dc:creator><description>&lt;p&gt;Like all readers of your blog (I hope), I just checked my company's code. &amp;nbsp; I found that (ahem) I had already done this check. &amp;nbsp;Not only that, but I found that:&lt;/p&gt;
&lt;p&gt;// of the 2906 messages in winerror.h, &lt;/p&gt;
&lt;p&gt;// &amp;nbsp; 2874 messages take no parameters&lt;/p&gt;
&lt;p&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp;26 messages take 1 parameter&lt;/p&gt;
&lt;p&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp;5 messages take 2 parameters&lt;/p&gt;
&lt;p&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp;1 message takes 3 parameters&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6585971</link><pubDate>Thu, 29 Nov 2007 01:12:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6585971</guid><dc:creator>f0dder</dc:creator><description>&lt;p&gt;Thanks, that's indeed something you could get bitten by. Fortunately, I've only ever used FormatMessage by copy-pasting the example snippet from MSDN, which thankfully has IGNORE_INSERTS :)&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6586397</link><pubDate>Thu, 29 Nov 2007 01:54:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6586397</guid><dc:creator>GreaseMonkey</dc:creator><description>&lt;p&gt;Reminds me of AOE 2: &amp;quot;Click here to select this %s.&amp;quot;&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6593806</link><pubDate>Thu, 29 Nov 2007 10:06:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6593806</guid><dc:creator>Worf</dc:creator><description>&lt;p&gt;Is it just me, or does FormatMessage end up being a huge PITA function to actually use? Nevermind this flag and the random number of insertions (more errors can be added as time goes on, so you can't ever predict the error down the road...), but just trying to return something useful to the user.&lt;/p&gt;
&lt;p&gt;Especially when a decent C library has strerror() the takes one argument - the error number - and returns a static pointer to localized error messages. Which can then be used directly via %s and friends inline... a nice simple to use function.&lt;/p&gt;
&lt;p&gt;At least, I've given up using FormatMessage...&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6595597</link><pubDate>Thu, 29 Nov 2007 12:26:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6595597</guid><dc:creator>Neil</dc:creator><description>&lt;p&gt;It looks as if this faulty code snippet was lifted from net.exe - try &amp;quot;net helpmsg 193&amp;quot; - although ironically message 3871 which does include an insert has had to be special-cased!&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6595881</link><pubDate>Thu, 29 Nov 2007 12:48:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6595881</guid><dc:creator>Ruslan</dc:creator><description>
&lt;p&gt;I know you moderate comments, so this is an appropriate way to respond you regarding your previous post, without irrelevant stuff appearing in this one.&lt;/p&gt;

&lt;p&gt;Agree, I wrote bullshit myself, so there's no arguing here. My apologies for being not polite. But there's I thought I'd convey.&lt;/p&gt;

&lt;p&gt;Putin's done a lot for Russia. Probably, as much as the harm Bush has done for the US (but with a positive sign, and not in absolute numbers, because the US economy is bigger). So, no doubt, Putin remaining in power is good for Russia. Of course, not in a such stupid way as changing or breaching the constitution, as that'd be not good for Russia. So all critics about Putin remaining in power is wrong in two ways: wrong in principle, and wrong in that he'll try to break the law.&lt;/p&gt;

&lt;p&gt;In case you wonder: I'm not a Putin fan. There're things that have become worse during his rule; and there're things that haven't improved. (that's why I immigrated) But it's nothing compared to the good things he's done. You'd not expect a human to be 100% flawless, right?&lt;/p&gt;

&lt;p&gt;And, third, you blame Putin and write what you write (which is your 100% right, of course) because you are a victim of Western propaganda. You Americans believe in freedom of your mass media so much that you apparently don't question its objectiveness. It's good, indeed, and I've been following it for quite a while. So what I also noticed is that it's not free from engagement and sometimes serves as a media for distributing disinformation, even to Americans themselves. It was so about Yugoslavia, Iraq, etc. In relation to Putin, the position of the Western mass media is always negative. Yet your investment banks (I work in one of them) increase their investments into Russia by billions every half year. Would they do so if they thought situation in Russia deteriorates?&lt;/p&gt;
&lt;div class="post"&gt;[&lt;i&gt;If you want to respond to me personally, then send me email. Don't hijack an unrelated thread. And I think you missed the part of my message where I explicitly pointed out that I don't have a position on whether it was a good idea that Putin stay in power (I don't know enough as you more than amply rant on -- not sure why you're ranting about something I already admitted); I was merely being amused at all the effort at figuring out &lt;u&gt;how&lt;/u&gt; to do it. Normally I would delete this comment but then it would confirm your incorrect assumption that doing so was acceptable behavior. -Raymond&lt;/i&gt;]&lt;/div&gt;</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6596398</link><pubDate>Thu, 29 Nov 2007 13:20:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6596398</guid><dc:creator>Mikael Vejdemo Johansson</dc:creator><description>&lt;p&gt;Wow. Russian political spam.&lt;/p&gt;</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6597649</link><pubDate>Thu, 29 Nov 2007 15:31:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6597649</guid><dc:creator>pingpong</dc:creator><description>&lt;p&gt;@Ruslan:&lt;/p&gt;
&lt;p&gt;You're not a Putin fan, but you decide to defend him in the technical topic. Is there a real Putin fan standing nearby, holding a gun next to your head?&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6601588</link><pubDate>Thu, 29 Nov 2007 22:34:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6601588</guid><dc:creator>DriverDude</dc:creator><description>&lt;p&gt;It seems to me that FormatMessage was intended for locale-specific message lookup, more like gettext rather than the simplistic strerror.&lt;/p&gt;
&lt;p&gt;As with anything that complicated, perhaps over time people forgot how FormatMessage is used. Insertion strings are great if the caller knows what to insert; caller doesn't have to be concered where to insert it. Not so great as a generic error message lookup facility.&lt;/p&gt;
&lt;p&gt;For example, there are plenty of erorr messages of the form &amp;quot;Semaphore period expired&amp;quot; or &amp;quot;File not found&amp;quot;, instead of &amp;quot;%1 could not be found&amp;quot; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Seems to me the person who added ERROR_BAD_EXE_FORMAT forgot that FormatText is sometimes used to generically translate error numbers. Or maybe that guideline was never published.&lt;/p&gt;
&lt;p&gt;Thanks for the lesson in software engineering, Raymond.&lt;/p&gt;
</description></item><item><title>re: The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag</title><link>http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx#6603468</link><pubDate>Fri, 30 Nov 2007 01:01:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6603468</guid><dc:creator>Anonymous Coward</dc:creator><description>&lt;p&gt;After reading this article (thanks for posting it btw - I discovered that we did indeed have this very same bug in our software as well), it seems like FORMAT_MESSAGE_IGNORE_INSERTS should be implied by FORMAT_MESSAGE_FROM_SYSTEM, and you should have to explicitly pass in another flag (maybe FORMAT_MESSAGE_ALLOW_INSERTS or something similar) to get the inserts expansion behavior. Of course I realize that it's too late for FormatMesssage - that ship has already sailed - but hopefully future APIs will not repeat the same design.&lt;/p&gt;
</description></item></channel></rss>