<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Bill Zitomer</title>
	
	<link>http://zitomerconsulting.com/blog</link>
	<description>C++ Programming and other random endeavors</description>
	<lastBuildDate>Thu, 16 Jul 2009 05:32:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/BillZitomer" /><feedburner:info uri="billzitomer" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Wordpress Import</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/gRxuQ_VXfKY/</link>
		<comments>http://zitomerconsulting.com/blog/2009/07/16/wordpress-import/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 05:29:12 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[wordpress import export 301]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/blog/?p=89</guid>
		<description><![CDATA[The import/export function in Wordpress seems to have some issues. The one I ran into was exporting from a blog hosted on wordpress.com to a blog hosted on a lunarpages site. For the most part it worked fine, except for the images. I got this error on all of the post attachments:
Remote file error: Remote [...]]]></description>
			<content:encoded><![CDATA[<p>The import/export function in Wordpress seems to have some issues. The one I ran into was exporting from a blog hosted on wordpress.com to a blog hosted on a lunarpages site. For the most part it worked fine, except for the images. I got this error on all of the post attachments:</p>
<p><code>Remote file error: Remote file returned error response 301 Moved Permanently</code></p>
<p>At first I thought it was a problem downloading from the wordpress site, and the few hits I got from Google seemed to confirm. But it turns out it&#8217;s a problem in the Wordpress code for importing. Thanks to the last post on <a href="http://en.forums.wordpress.com/topic/downloading-images-for-import?replies=4" target="blank">this page</a> I was able to solve it. Well, sort of. The fix to functions.php (btw the function to modify is wp_get_http) solved the 301 errors and the import successfully uploaded the images to my server. However, all of the images remained linked to the old server. </p>
<p>Blarg.</p>
<p>Having run the import several times over, I deleted everything and tried again. The images again transferred successfully, but in the posts they remained linked to the old site.</p>
<p>My last resort was to go into the control panel for my site and use the SQL tools to do a replace on strings in the Wordpress database. What a hassle.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/EAnDebW68VuR3mXzITytU0CPjNQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/EAnDebW68VuR3mXzITytU0CPjNQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/EAnDebW68VuR3mXzITytU0CPjNQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/EAnDebW68VuR3mXzITytU0CPjNQ/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/gRxuQ_VXfKY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2009/07/16/wordpress-import/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2009/07/16/wordpress-import/</feedburner:origLink></item>
		<item>
		<title>Feed Burner</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/xhbaesjYfQ4/</link>
		<comments>http://zitomerconsulting.com/blog/2009/06/07/feed-burner/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 17:19:59 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[FeedBurner]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/blog/?p=85</guid>
		<description><![CDATA[I added the FD Burner plugin. I burned my feed a couple hours ago (before the plugin), made a new post, and haven&#8217;t seen it show up in Google Reader yet. I&#8217;m making this post to see if it will show up now with the plugin.
]]></description>
			<content:encoded><![CDATA[<p>I added the FD Burner plugin. I burned my feed a couple hours ago (before the plugin), made a new post, and haven&#8217;t seen it show up in Google Reader yet. I&#8217;m making this post to see if it will show up now with the plugin.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/CWLDbx5GrFsAFxfY5AVhW6bulJU/0/da"><img src="http://feedads.g.doubleclick.net/~a/CWLDbx5GrFsAFxfY5AVhW6bulJU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/CWLDbx5GrFsAFxfY5AVhW6bulJU/1/da"><img src="http://feedads.g.doubleclick.net/~a/CWLDbx5GrFsAFxfY5AVhW6bulJU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/xhbaesjYfQ4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2009/06/07/feed-burner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2009/06/07/feed-burner/</feedburner:origLink></item>
		<item>
		<title>WordPress Plugins</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/Lv6C9bdm95s/</link>
		<comments>http://zitomerconsulting.com/blog/2009/06/07/wordpress-plugins/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 15:52:25 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/blog/?p=82</guid>
		<description><![CDATA[I&#8217;ve been trying out some plug-ins for WordPress. So far I like the NextGEN gallery and I also added New Tag Cloud. Still not happy with the tag cloud appearance. 
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying out some plug-ins for WordPress. So far I like the NextGEN gallery and I also added New Tag Cloud. Still not happy with the tag cloud appearance. </p>

<p><a href="http://feedads.g.doubleclick.net/~a/7PNIpn_EY3T0iUaPjzdWULtgrpA/0/da"><img src="http://feedads.g.doubleclick.net/~a/7PNIpn_EY3T0iUaPjzdWULtgrpA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/7PNIpn_EY3T0iUaPjzdWULtgrpA/1/da"><img src="http://feedads.g.doubleclick.net/~a/7PNIpn_EY3T0iUaPjzdWULtgrpA/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/Lv6C9bdm95s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2009/06/07/wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2009/06/07/wordpress-plugins/</feedburner:origLink></item>
		<item>
		<title>Template Class for Dynamic Linking</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/F-iHLjHk4As/</link>
		<comments>http://zitomerconsulting.com/blog/2009/06/05/template-class-for-dynamic-linking/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 22:32:03 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[DLL]]></category>
		<category><![CDATA[dynamic linking]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[template class]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/blog/?p=44</guid>
		<description><![CDATA[Dynamic linking (or runtime linking) is the method of finding and calling a function in a DLL at runtime. The most common use for it is when you can&#8217;t be certain that the DLL or function will exist. For example, if you calling a new WINAPI function which only exists in Vista, but you want [...]]]></description>
			<content:encoded><![CDATA[<p>Dynamic linking (or runtime linking) is the method of finding and calling a function in a DLL at runtime. The most common use for it is when you can&#8217;t be certain that the DLL or function will exist. For example, if you calling a new WINAPI function which only exists in Vista, but you want your application to still run on XP, you will need to use dynamic linking. </p>
<p>The process is simple: load the DLL, get the address of the function and make the call. You need just 3 WNAPI calls to get the job done. Of course, there is error checking too, so a typical function call requires several lines of code, and if you want to save the pointer for use later, you still have worry about keeping track of the handle to the DLL and releasing it when you are done.</p>
<p>So I made a template class to encapsulate the entire process, creating essentially a smart pointer for dynamic functions. </p>
<pre id="codeblock"><code>template &lt;typename FunctionPtr&gt; class CDynamicFunction
{
public:
    // Constructor automatically binds the function.
    CDynamicFunction(CString dllName, CString procName)
    {
        _module = ::LoadLibrary(dllName);
        if (_module == NULL)
        {
            // error, DLL probably doesn't exist
            _procAddress = NULL;
        }
        else
        {
            // Get the function pointer - this will be NULL if the function doesn't exist.
            _procAddress = (FunctionPtr)(::GetProcAddress(_module,procName));
        }
    }

    // Destructor automatically releases the DLL.
    virtual ~CDynamicFunction(void)
    {
        if (_module != NULL)
        {
            ::FreeLibrary(_module);
            _module = NULL;
        }
    }

    // Use this method like a regular function. Check for NULL first, in case the function
    // couldn't be linked.
    virtual operator FunctionPtr()
    {
        return _procAddress;
    }

private:
    HMODULE     _module;
    FunctionPtr _procAddress;
};</code></pre>
<p>To use the template class do the following:</p>
<p>1. Typedef a pointer to the function you want to import. The syntax below is for a Windows API call, but you can define it as needed.</p>
<div id="codeblock"><code>typedef LONG (WINAPI *pMyEntryPoint) (HWND hwnd, int xyz);</code></div>
<p>2. Instantiate the class either in a local stack frame, or in another class. The DLL is loaded upon instantiation and it will be automatically unloaded when the class goes out of scope. </p>
<div id="codeblock"><code>CDynamicFunction&lt;pMyEntryPoint&gt; myEntryPoint("blah.dll", "MyEntryPoint");</code></div>
<p>3. Check the result of the class and call your function:</p>
<pre id="codeblock"><code>if(myEntryPoint == NULL)
{
    // handle error
}
else
{
    LONG result = myEntryPoint(hwnd, x);
}</code></pre>
<p>Simple and reliable, and it avoids the common errors that come from writing the same code in many different places.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/rOIQAv7027zZsVVwV_o7hWH-RKQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/rOIQAv7027zZsVVwV_o7hWH-RKQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/rOIQAv7027zZsVVwV_o7hWH-RKQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/rOIQAv7027zZsVVwV_o7hWH-RKQ/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/F-iHLjHk4As" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2009/06/05/template-class-for-dynamic-linking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2009/06/05/template-class-for-dynamic-linking/</feedburner:origLink></item>
		<item>
		<title>I’m Back</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/5SDjQYVCmac/</link>
		<comments>http://zitomerconsulting.com/blog/2009/06/05/im-back/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 21:51:54 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/blog/?p=41</guid>
		<description><![CDATA[I&#8217;m redoing this blog. I am determined to start posting something more than once a year. I decided to drop the consulting angle, which went nowhere as soon as W3i turned me into an employee. So this blog will be about the stuff I&#8217;m doing in general &#8211; work and play. Let&#8217;s see how long [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m redoing this blog. I am determined to start posting something more than once a year. I decided to drop the consulting angle, which went nowhere as soon as W3i turned me into an employee. So this blog will be about the stuff I&#8217;m doing in general &#8211; work and play. Let&#8217;s see how long I can keep it going this time&#8230;</p>

<p><a href="http://feedads.g.doubleclick.net/~a/HOJ4aPHqttT3fN5RGUgMotPLge4/0/da"><img src="http://feedads.g.doubleclick.net/~a/HOJ4aPHqttT3fN5RGUgMotPLge4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/HOJ4aPHqttT3fN5RGUgMotPLge4/1/da"><img src="http://feedads.g.doubleclick.net/~a/HOJ4aPHqttT3fN5RGUgMotPLge4/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/5SDjQYVCmac" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2009/06/05/im-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2009/06/05/im-back/</feedburner:origLink></item>
		<item>
		<title>Bad Programming</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/gosMzdj_QuU/</link>
		<comments>http://zitomerconsulting.com/blog/2008/11/19/bad-programming/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 15:09:44 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bad programming]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/blog/?p=15</guid>
		<description><![CDATA[I&#8217;ve got a few boneheaded mistakes I make over and over again, as I&#8217;m sure every programmer does. The one I&#8217;ve been making lately is with CString&#8217;s CompareNoCase method, thinking it returns TRUE/FALSE when it actually returns -1/0/1 (like the CRT strcmp function). Basically I wrote this:
if (str.CompareNoCase(&#38;quot;blarg&#38;quot;))
instead of writing:
if (str.CompareNoCase(&#38;quot;blarg&#38;quot;) == 0)
Obviously it produced [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a few boneheaded mistakes I make over and over again, as I&#8217;m sure every programmer does. The one I&#8217;ve been making lately is with CString&#8217;s CompareNoCase method, thinking it returns TRUE/FALSE when it actually returns -1/0/1 (like the CRT strcmp function). Basically I wrote this:</p>
<div id="codeblock"><code>if (str.CompareNoCase(&amp;quot;blarg&amp;quot;))</code></div>
<p>instead of writing:</p>
<div id="codeblock"><code>if (str.CompareNoCase(&amp;quot;blarg&amp;quot;) == 0)</code></div>
<p>Obviously it produced the exact opposite result. I just did it again yesterday and spent the better part of an hour tracing through code, adding log messages, pulling my hair out trying to figure out why a bit of code wasn&#8217;t working, before I finally realized the mistake.</p>
<p>Blarg.</p>
<p>I think it&#8217;s bad programming to have written the CompareNoCase method this way in the first place. It should be a BOOL method, or at least there should be another BOOL method available. I&#8217;ve used CompareNoCase a lot but I can&#8217;t recall ever using it for a relative comparison.</p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:d246fec5-2833-48c9-98d0-5c2a379f54ed" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/bad%20programming" rel="tag">bad programming</a>,<a href="http://technorati.com/tags/c++" rel="tag">c++</a></div>

<p><a href="http://feedads.g.doubleclick.net/~a/vQgkqdAdZg10k6I2-qataFvjoS4/0/da"><img src="http://feedads.g.doubleclick.net/~a/vQgkqdAdZg10k6I2-qataFvjoS4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vQgkqdAdZg10k6I2-qataFvjoS4/1/da"><img src="http://feedads.g.doubleclick.net/~a/vQgkqdAdZg10k6I2-qataFvjoS4/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/gosMzdj_QuU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2008/11/19/bad-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2008/11/19/bad-programming/</feedburner:origLink></item>
		<item>
		<title>Export from WordPress</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/zMM1N_WRyGA/</link>
		<comments>http://zitomerconsulting.com/blog/2008/10/30/export-from-wordpress/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 22:01:52 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/blog/?p=14</guid>
		<description><![CDATA[Haven&#8217;t posted anything in a while. I finally moved my blog over to my new host but when I did the export it lost all of my tags. WTF? 
Technorati Tags: wordpress export
]]></description>
			<content:encoded><![CDATA[<p>Haven&#8217;t posted anything in a while. I finally moved my blog over to my new host but when I did the export it lost all of my tags. WTF? </p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:45021e64-ca02-43d9-8fd3-98616e913c77" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/wordpress%20export" rel="tag">wordpress export</a></div>

<p><a href="http://feedads.g.doubleclick.net/~a/QHCaIiYVFdT1aRBgsEm76P2cyjk/0/da"><img src="http://feedads.g.doubleclick.net/~a/QHCaIiYVFdT1aRBgsEm76P2cyjk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/QHCaIiYVFdT1aRBgsEm76P2cyjk/1/da"><img src="http://feedads.g.doubleclick.net/~a/QHCaIiYVFdT1aRBgsEm76P2cyjk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/zMM1N_WRyGA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2008/10/30/export-from-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2008/10/30/export-from-wordpress/</feedburner:origLink></item>
		<item>
		<title>Version Info</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/nAfA1Id4M7c/</link>
		<comments>http://zitomerconsulting.com/blog/2008/02/16/version-info/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 04:14:19 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Version Resource]]></category>
		<category><![CDATA[Windows API]]></category>
		<category><![CDATA[Windows programming]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/WordPress/2008/02/16/version-info/</guid>
		<description><![CDATA[You would think that retrieving version information from a program would be a basic and simple task. For example if you want to display your version number in an About box. For a long time I&#8217;ve stored version numbers in a resource (as they should be) but used a separate #define in the code, which [...]]]></description>
			<content:encoded><![CDATA[<p>You would think that retrieving version information from a program would be a basic and simple task. For example if you want to display your version number in an About box. For a long time I&#8217;ve stored version numbers in a resource (as they should be) but used a separate #define in the code, which is easy to access and display in an About box. Finally I got tired of this redundancy and dug up some old code I had (circa 1998!) and holy crap, it still works. And holy crap, the <a href="http://msdn2.microsoft.com/en-us/library/ms646981(VS.85).aspx" target="_blank">API</a> hasn&#8217;t changed either.</p>
<p>The code was in C, and ugly, so I made a new class based on the old code. It has a static method to get the fixed portion of the version resource, and another method to get a string. one to get a string.  Here is the string version:</p>
<pre id="codeblock"><code>CString CMyVersion::GetStringItem (CString modulename, CString itemName)
{
    CString result = "";
    if (modulename.IsEmpty())
    {
        modulename = CCoreFile::GetProgramPath();
    }

    DWORD handle; // not used, will be set to 0.
    DWORD size = ::GetFileVersionInfoSize (modulename, &amp;handle);
    if (size &gt; 0)
    {
        VOID* block = ::HeapAlloc (::GetProcessHeap(), HEAP_ZERO_MEMORY, size);
        if (block != NULL)
        {
            if (::GetFileVersionInfo (modulename, 0, size, block))
            {
                // The pointer returned in buffer is freed automatically when block is freed.
                // This assumes the english language block
                itemName = "\StringFileInfo\040904E4" + itemName;
                LPBYTE buffer;
                UINT length;
                if (::VerQueryValue (block, itemName, (LPVOID*)&amp;buffer, &amp;length))
                {
                    result = CString(buffer);
                }
            }

            ::HeapFree(::GetProcessHeap(), 0, block);
        }
    }

    return result;
}</code></pre>
<p>Note the limitation, this method assumes you want an item in the English language version of the StringFileInfo block. Since I don&#8217;t foresee myself needing my version number in Swahili, I think this limitation will be fine.</p>
<p>To get the file or product version using this class:</p>
<div id="codeblock">
<code>CString fileVersion = CMyVersion::GetStringItem(modulename, "FileVersion");</code><br />
<br />
<code>CString productVersion = CMyVersion::GetStringItem(modulename, "ProductVersion");</code>
</div>
<p>Getting the fixed part of the version resource is similar:</p>
<pre id="codeblock"><code>BOOL CMyVersion::GetFixedInfo (CString modulename, VS_FIXEDFILEINFO* info)
{
    BOOL result = FALSE;

    if (modulename.IsEmpty())
    {
        modulename = CCoreFile::GetProgramPath();
    }

    DWORD handle; // not used, will be set to 0.
    DWORD size = ::GetFileVersionInfoSize (modulename, &amp;handle);
    if (size &gt; 0)
    {
        VOID* block = ::HeapAlloc (::GetProcessHeap(), HEAP_ZERO_MEMORY, size);
        if (block != NULL)
        {
            if (::GetFileVersionInfo (modulename, 0, size, block))
            {
                // The pointer returned in buffer is freed automatically when block is freed.
                LPBYTE buffer;
                UINT length;
                if (::VerQueryValue (block, “\”, (LPVOID*)&amp;buffer, &amp;length))
                {
                    length = min(length, sizeof(*info));
                    ::CopyMemory(info, buffer, length);
                    result = TRUE;
                }
            }

            ::HeapFree(::GetProcessHeap(), 0, block);
        }
    }

    return result;
}</code></pre>
<p>The <a href="http://msdn2.microsoft.com/en-us/library/ms646981(VS.85).aspx" target="_blank">Windows Version API</a> certainly is robust, and supportive of multiple languages, but for goodness sake, didn&#8217;t the author realize that most of its usefulness would be in retrieving a version number? Why go through all of this nonsense for such a simple task?</p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:defb5ae3-e732-42c8-8091-afa0bd1cdfbc" class="wlWriterSmartContent" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"><span style="color: #808080; font-size: xx-small;">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Windows%20programming">Windows programming</a>,<a rel="tag" href="http://technorati.com/tags/Windows%20API">Windows API</a>,<a rel="tag" href="http://technorati.com/tags/Version%20Resource">Version Resource</a>,<a rel="tag" href="http://technorati.com/tags/C++">C++</a></span></div>

<p><a href="http://feedads.g.doubleclick.net/~a/Z22veIBmtYLyVcjDuI1xpZoLuCs/0/da"><img src="http://feedads.g.doubleclick.net/~a/Z22veIBmtYLyVcjDuI1xpZoLuCs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Z22veIBmtYLyVcjDuI1xpZoLuCs/1/da"><img src="http://feedads.g.doubleclick.net/~a/Z22veIBmtYLyVcjDuI1xpZoLuCs/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/nAfA1Id4M7c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2008/02/16/version-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2008/02/16/version-info/</feedburner:origLink></item>
		<item>
		<title>Deleting Browser History</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/11w-vUDOnfI/</link>
		<comments>http://zitomerconsulting.com/blog/2007/10/12/deleting-browser-history/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 06:24:24 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/WordPress/2007/10/12/deleting-browser-history/</guid>
		<description><![CDATA[Here is another exercise in futility. Using the IE ActiveX (er, COM?) interface to automate Internet Explorer. I&#8217;ve got an app that navigates to a web page, but I don&#8217;t want it to leave an entry in the browser history list. Sounds simple enough. And hey look, there&#8217;s a flag you can pass to the [...]]]></description>
			<content:encoded><![CDATA[<p>Here is another exercise in futility. Using the IE ActiveX (er, COM?) interface to automate Internet Explorer. I&#8217;ve got an app that navigates to a web page, but I don&#8217;t want it to leave an entry in the browser history list. Sounds simple enough. And hey look, there&#8217;s a flag you can pass to the IWebBrowser2.Navigate method: navNoHistory. Sweet!</p>
<p>I thought I was done in 10 minutes. But it turns out, that flag only pertains to the browser&#8217;s <em>session</em> history. Not the <em>global</em> history, which is where you see your link listed in the side-bar when you open the history list. Doh!</p>
<p>As usual, <a href="http://msdn2.microsoft.com/en-us/library/aa768360.aspx" target="_blank">the docs</a> are completely vague and unhelpful:</p>
<blockquote><p>navNoHistory &#8211; Do not add the resource or file to the history list. The new page replaces the current page in the list.</p>
</blockquote>
<p>Nothing about sessions versus global. And new page replaces the wha?</p>
<p>Ok, so I poked around some more and found another interface: IUrlHistoryStg. And look, it has a method: DeleteUrl. Well surely I&#8217;m done now. <a href="http://support.microsoft.com/kb/327569" target="_blank">Not.</a> </p>
<p>Ok. Here is what it says under More Information in that article:</p>
<blockquote><p><strong>DeleteUrl</strong> is not designed to delete the Internet Explorer History Shell folder entries.</p>
</blockquote>
<p>Just great. The method to delete urls from the history folder is not designed to delete urls from the history folder. But wait&#8230;you can use this other method that requires 15x more lines of code, and pops up a dialog box which you can&#8217;t suppress. Just freaking brilliant!</p>
<p>Plan C: Wininet always has something. Yeah. Well, sort of. Ok, not really. &lt;sigh&gt; DeleteUrlCacheEntry yielded the same results: successful operation, but the history entry remained.</p>
<p>I should point out, the result codes for either of these methods&#xA0; indicated the operations were successful. I also tried feeding them bogus urls, to verify they would fail on bad data, and they did. So both IUrlHistoryStg.DeleteUrl and WinInet&#8217;s DeleteUrlCacheEntry will tell you they successfully deleted your url, but in fact didn&#8217;t.</p>
<p>Lovely.</p>
<p>I spent the better part of a day on this, by the way. I also tried traversing the cache and overwriting what was there, but none of it worked. </p>
<p>I should also point out, these Delete Url imposters may actually work, as according to the docs, when you delete a url, it is only flagged, and&#xA0; whenever the &quot;cache scavenger&quot; feels like getting off it&#8217;s lazy ass and doing its job, it will then actually delete the url. Anyone got an API call for &quot;kick-the-lazy-ass-welfare-sucking-cache-scavenger-into-high-gear&quot;??</p>
<p>But I digress. It might be nice if once in a while Microsoft could document their API&#8217;s as such: &quot;DeleteUrl is a fictitious API that looks like it might do what you want it to do, but after you spend 3 hours testing it out, will actually turn out to do nothing but leave you feeling empty and jaded.&quot; Of course, if I ever read such an entry in the help file, I would probably spend the 3 hours finding out that it didn&#8217;t (er, did?) work as advertised. <img src='http://zitomerconsulting.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/vyujkmzlefcIArEzNIf9yw8E7qI/0/da"><img src="http://feedads.g.doubleclick.net/~a/vyujkmzlefcIArEzNIf9yw8E7qI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vyujkmzlefcIArEzNIf9yw8E7qI/1/da"><img src="http://feedads.g.doubleclick.net/~a/vyujkmzlefcIArEzNIf9yw8E7qI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/11w-vUDOnfI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2007/10/12/deleting-browser-history/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2007/10/12/deleting-browser-history/</feedburner:origLink></item>
		<item>
		<title>Stoopid Intarweb</title>
		<link>http://feedproxy.google.com/~r/BillZitomer/~3/xJSxbR7PIT8/</link>
		<comments>http://zitomerconsulting.com/blog/2007/10/11/stoopid-intarweb/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 18:38:24 +0000</pubDate>
		<dc:creator>Bill Zitomer</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://zitomerconsulting.com/WordPress/2007/10/11/stoopid-intarweb/</guid>
		<description><![CDATA[Can&#8217;t figure out why the middle keeps shifting down on this thing. Blarg.
]]></description>
			<content:encoded><![CDATA[<p>Can&#8217;t figure out why the middle keeps shifting down on this thing. Blarg.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Ezjy5ASvehmXj3vqjcNJS-T3bYk/0/da"><img src="http://feedads.g.doubleclick.net/~a/Ezjy5ASvehmXj3vqjcNJS-T3bYk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Ezjy5ASvehmXj3vqjcNJS-T3bYk/1/da"><img src="http://feedads.g.doubleclick.net/~a/Ezjy5ASvehmXj3vqjcNJS-T3bYk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/BillZitomer/~4/xJSxbR7PIT8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://zitomerconsulting.com/blog/2007/10/11/stoopid-intarweb/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://zitomerconsulting.com/blog/2007/10/11/stoopid-intarweb/</feedburner:origLink></item>
	</channel>
</rss>
