<?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>When good functions [seem to] go bad</title><link>http://blogs.msdn.com/b/michkap/archive/2011/02/11/10128045.aspx</link><description>In many cases it isn't the question that is complicated; it is the impact of surrounding features that make the answers so complicated! 
 A while back, the question that was asked was: 
 Hello, 
 I&amp;rsquo;m trying to get the file version for mshtml</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: When good functions [seem to] go bad</title><link>http://blogs.msdn.com/b/michkap/archive/2011/02/11/10128045.aspx#10128334</link><pubDate>Fri, 11 Feb 2011 23:11:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10128334</guid><dc:creator>Jeremy Drake</dc:creator><description>&lt;p&gt;@Little Commenter: the docs for GetFileVersionInfoEx say of FILE_VER_GET_NEUTRAL: &amp;quot;This flag must be combined with FILE_VER_GET_LOCALISED.&amp;quot; &amp;nbsp;The description of what happens in this case seems to match the behavior of GetFileVersionInfo, which is what the original poster had problems with.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10128334" width="1" height="1"&gt;</description></item><item><title>re: When good functions [seem to] go bad</title><link>http://blogs.msdn.com/b/michkap/archive/2011/02/11/10128045.aspx#10128266</link><pubDate>Fri, 11 Feb 2011 20:51:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10128266</guid><dc:creator>Little Commenter</dc:creator><description>&lt;p&gt;GetFileVersionInfo is getting info from MUI files (when available) and merges this info with fixed info from language neutral file.&lt;/p&gt;
&lt;p&gt;My proposed answer: Use GetFileVersionInfoEx and pass as first parameter FILE_VER_GET_NEUTRAL. This way you will obtain the resource from the language neutral file, not from the MUI file.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10128266" width="1" height="1"&gt;</description></item><item><title>re: When good functions [seem to] go bad</title><link>http://blogs.msdn.com/b/michkap/archive/2011/02/11/10128045.aspx#10128207</link><pubDate>Fri, 11 Feb 2011 18:48:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10128207</guid><dc:creator>Jeremy Drake</dc:creator><description>&lt;p&gt;It&amp;#39;s always good when you can tell the user to RTFM:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/ms647003(v=VS.85).aspx"&gt;msdn.microsoft.com/.../ms647003(v=VS.85).aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/p&gt;
&lt;p&gt;Remarks&lt;/p&gt;
&lt;p&gt;File version info has fixed and non-fixed part. The fixed part contains information like version number. The non-fixed part contains things like strings. In the past GetFileVersionInfo was taking version information from the binary (exe/dll). Currently, it is querying fixed version from language neutral file (exe/dll) and the non-fixed part from mui file, merges them and returns to the user.&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/p&gt;
&lt;p&gt;I suppose you could format the version number yourself from the fixed part (the binary version number). &amp;nbsp;That&amp;#39;s what I tend to do (though I don&amp;#39;t put anything other than the raw dot-delimited four-part version number in the string version field). &amp;nbsp;Or you could try to convince GetFileVersionInfoEx to give you the lauguage-neutral non-fixed data (though the FM on that function doesn&amp;#39;t tell you what flag to pass for that, I assume it&amp;#39;s 0, none of the above), if you can even use that function since it is only available on Vista+, and most people still have to support at least XP. &amp;nbsp;Or you could use the resource functions directly to look up the RT_VERSION data (FindResourceEx says passing MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) gives you the resources for the current thread&amp;#39;s current language, so how would you specify you want the neutral version of the resources?). &amp;nbsp;Or if all that fails, you could always go traipsing around in the PE file format and that way be sure nobody&amp;#39;s pulling any slight-of-hand with which file&amp;#39;s data you get back. &amp;nbsp;In case you can&amp;#39;t tell, I tend to really hate it when the system thinks it&amp;#39;s smarter than me and tells me &amp;quot;You asked for info from *this* file? &amp;nbsp;I&amp;#39;m sure what you really wanted is info from this *OTHER* file, so I&amp;#39;ll just return that instead.&amp;quot; &amp;nbsp;That&amp;#39;s right up there with &amp;quot;You want to know what version of Windows you&amp;#39;re running on? &amp;nbsp;Good luck with that. &amp;nbsp;Here, let me *lie to you* about that so you can try to load the wrong driver and with any luck, that will bluescreen the system and really annoy the user.&amp;quot;&lt;/p&gt;
&lt;p&gt;But let&amp;#39;s go back to the original question for a second. &amp;nbsp;Trying to query the version of a DLL at runtime generally tends to be used for figuring out if it supports a given feature. &amp;nbsp;Better to test for that feature directly, and only if that&amp;#39;s not possible, fall back to comparing the binary version from the &amp;quot;fixed data&amp;quot; that&amp;#39;s not returned from the MUI anyway.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10128207" width="1" height="1"&gt;</description></item><item><title>re: When good functions [seem to] go bad</title><link>http://blogs.msdn.com/b/michkap/archive/2011/02/11/10128045.aspx#10128170</link><pubDate>Fri, 11 Feb 2011 17:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10128170</guid><dc:creator>Ivan Rouzanov</dc:creator><description>&lt;p&gt;&amp;quot;In the past GetFileVersionInfo was taking version information from the binary (exe/dll). Currently, it is querying fixed version from language neutral file (exe/dll) and the non-fixed part from mui file, merges them and returns to the user. If the given binary does not have a mui file then behavior is as in previous version.&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/ms647003(VS.85).aspx"&gt;msdn.microsoft.com/.../ms647003(VS.85).aspx&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10128170" width="1" height="1"&gt;</description></item><item><title>re: When good functions [seem to] go bad</title><link>http://blogs.msdn.com/b/michkap/archive/2011/02/11/10128045.aspx#10128090</link><pubDate>Fri, 11 Feb 2011 15:50:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10128090</guid><dc:creator>Milan</dc:creator><description>&lt;p&gt;Acording to documentation (&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/ms647003(v=vs.85).aspx"&gt;msdn.microsoft.com/.../ms647003(v=vs.85).aspx&lt;/a&gt;):&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;File version info has fixed and non-fixed part. The fixed part contains information like version number. The non-fixed part contains things like strings. In the past GetFileVersionInfo was taking &lt;/p&gt;
&lt;p&gt;version information from the binary (exe/dll). Currently, it is querying fixed version from language neutral file (exe/dll) and the non-fixed part from mui file, merges them and returns to the user. If the given binary does not have a mui file then behavior is as in previous version.&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;My .mui contains &amp;quot;File Version: 8.00.6001.18702 (longhorn_ie8_rtm(wmbla).090308-0339)&amp;quot; in it&amp;#39;s dynamic part so GetFileVersionInfo returns it.&lt;/p&gt;
&lt;p&gt;I guess filever is not using GetFileVersionInfo but parses resource directly.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10128090" width="1" height="1"&gt;</description></item><item><title>re: When good functions [seem to] go bad</title><link>http://blogs.msdn.com/b/michkap/archive/2011/02/11/10128045.aspx#10128067</link><pubDate>Fri, 11 Feb 2011 15:25:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10128067</guid><dc:creator>Michael S. Kaplan</dc:creator><description>&lt;p&gt;Go on...&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10128067" width="1" height="1"&gt;</description></item><item><title>re: When good functions [seem to] go bad</title><link>http://blogs.msdn.com/b/michkap/archive/2011/02/11/10128045.aspx#10128064</link><pubDate>Fri, 11 Feb 2011 15:15:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10128064</guid><dc:creator>Milan</dc:creator><description>&lt;p&gt;With hint it&amp;#39;s trivial, there&amp;#39;s .mui file involved.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10128064" width="1" height="1"&gt;</description></item></channel></rss>