<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Visual C++ Tips &#187; Glorious Bugs</title>
	<atom:link href="http://weseetips.com/category/glorious-bugs/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>_chdir() pitfall &#8211; error while opening file.</title>
		<link>http://weseetips.com/2008/10/04/chdir-pitfall-error-while-opening-file/</link>
		<comments>http://weseetips.com/2008/10/04/chdir-pitfall-error-while-opening-file/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 20:32:45 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Glorious Bugs]]></category>
		<category><![CDATA[Windows APIs]]></category>
		<category><![CDATA[chdir()]]></category>
		<category><![CDATA[file not found]]></category>
		<category><![CDATA[file open pitfall]]></category>
		<category><![CDATA[GetModuleFileName()]]></category>
		<category><![CDATA[MAX_PATH]]></category>
		<category><![CDATA[PathRemoveFileSpec()]]></category>
		<category><![CDATA[SetCurrentDirectory()]]></category>
		<category><![CDATA[Shlwapi.lib]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=483</guid>
		<description><![CDATA[I still remember that bug! Because it grabbed my two days and delayed the delivery. Well, the story goes like this &#8211; It was during late summer of 2004. I was working in a DVD writer project. Internally we were using a third party DVD writer library named BHA Gold. Well, my project was a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.wordpress.com/files/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
<span style="color:#0000ff;">I still remember that bug! </span>Because it <span style="color:#0000ff;">grabbed my two days</span> and <span style="color:#0000ff;">delayed the delivery.</span> Well, the story goes like this &#8211; <span style="color:#0000ff;">It was during late summer of 2004.</span> I was <span style="color:#0000ff;">working in a DVD writer project</span>. <span style="color:#0000ff;">Internally </span>we were using a <span style="color:#0000ff;">third party DVD writer library named BHA Gold</span>. Well, my project was a wrapper library for the BHA Gold library.</p>
<p>Well, the bug was this &#8211; <span style="color:#0000ff;">There is a config file in my project,</span> which <span style="color:#0000ff;">exist in the same folder</span>, together with exe. <span style="color:#0000ff;">Before writing DVD,</span> I&#8217;ve to <span style="color:#0000ff;">read some settings from the config file</span>. But the bug is this. During startup, I could open the file. <span style="color:#0000ff;">But if I write one DVD using BHA gold, then when i tried to open the same file once again, it shows error!</span></p>
<p><img class="alignnone size-full wp-image-496" title="filenotfound" src="http://weseetips.wordpress.com/files/2008/10/filenotfound.jpg" alt="" width="504" height="504" /></p>
<p><img class="alignnone size-medium wp-image-15" title="icon_underthehood" src="http://weseetips.wordpress.com/files/2008/03/icon_underthehood.jpg?w=208" alt="" width="208" height="32" /><br />
At last its been found that the culprit is the api &#8211; _<span style="color:#0000ff;">chdir()</span>. The <span style="color:#888888;"><span style="color:#0000ff;">DVD writing library</span> </span>was <span style="color:#0000ff;">calling this api internally </span>to <span style="color:#0000ff;">prepare the directory tree,</span> and <span style="color:#0000ff;">once this api is called, the default directory will be changed to the specified directory </span>and during <span style="color:#0000ff;">next time, while opening the setting file,</span> it shows an <span style="color:#0000ff;">error that &#8220;file not found&#8221;! Since the setting file does not exist in the new default directory.<br />
</span></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.wordpress.com/files/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
Well, in such cases you could use the api &#8211; <span style="color:#0000ff;">SetCurrentDirectory()</span>. See the code snippet to set the current directory as exe&#8217;s folder path.</p>
<pre>#include "Shlwapi.h"
...
// Get the full path of current exe file.
TCHAR FilePath[MAX_PATH] = { 0 };
GetModuleFileName( 0, FilePath, MAX_PATH );

// Strip the exe filename from path and get folder name.
PathRemoveFileSpec( FilePath );    

// Set the current working directory.
SetCurrentDirectory( FilePath );</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.wordpress.com/files/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Don&#8217;t forget to add <span style="color:#0000ff;">Shlwapi.lib</span> to project settings. <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img class="alignnone size-medium wp-image-53" title="intermediateseries" src="http://weseetips.wordpress.com/files/2008/03/advancedseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audience &#8211; Advanced.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/10/04/chdir-pitfall-error-while-opening-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interesting bug in VisualStudio!</title>
		<link>http://weseetips.com/2008/07/15/interesting-bug-in-visualstudio/</link>
		<comments>http://weseetips.com/2008/07/15/interesting-bug-in-visualstudio/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 17:47:02 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Glorious Bugs]]></category>
		<category><![CDATA[&&]]></category>
		<category><![CDATA[ampersand in caption]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[control caption]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[visual studio 6.0]]></category>
		<category><![CDATA[Visual Studio bug]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=211</guid>
		<description><![CDATA[Once in technical forum, a guy asked how to add ampersand( &#38; ) symbol to control captions? Because the ampersand( &#38; ) symbol is used to specify the keyboard accelerator for the control. Have a look at my previous post - http://weseetips.com/2008/06/15/how-to-add-ampersand-symbol-to-dialog-control-captions/ Visual Studio, the ultimate creator &#8211; recommends to add &#38;&#38; to make ampersand [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
Once in technical forum, a guy asked <span style="color:#0000ff;">how to add ampersand( &amp; ) </span>symbol to control captions? Because the ampersand( &amp; ) symbol is used to specify the <span style="color:#0000ff;">keyboard accelerator</span> for the control. Have a look at my previous post -<br />
<a title="http://weseetips.com/2008/06/15/how-to-add-ampersand-symbol-to-dialog-control-captions/" href="http://weseetips.com/2008/06/15/how-to-add-ampersand-symbol-to-dialog-control-captions/" target="_blank">http://weseetips.com/2008/06/15/how-to-add-ampersand-symbol-to-dialog-control-captions/</a></p>
<p>Visual Studio, the ultimate creator &#8211; recommends to add <span style="color:#0000ff;">&amp;&amp;</span> to make ampersand visible in control captions. But, does the creator himself suffer due to ampersand problem? <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Read on&#8230;</p>
<p><img class="alignnone size-medium wp-image-15" src="http://weseetips.files.wordpress.com/2008/03/icon_underthehood.jpg?w=208" alt="" width="208" height="32" /><br />
Have a look at the properties of Auto variable item in Visual Studio window. It suffers the same bug. The variable name is <span style="color:#0000ff;"><strong>&#8220;&amp;lResult&#8221;</strong></span>. But in the properties window, its displayed as <span style="color:#0000ff;"><strong>&#8220;<span style="text-decoration:underline;">l</span>Result&#8221;</strong></span>. See the screenshot.</p>
<p><img class="alignnone size-full wp-image-212" src="http://siteground205.com/~weseetip/wp-content/uploads/2008/07/autovariablewindow.jpg" alt="" width="510" height="246" /></p>
<p><img class="alignnone size-medium wp-image-18" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Pretty funny, nah? BTW, Was that guy from Microsoft? <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  (Just kidding)</p>
<p><span style="color:#0000ff;">But I always bow my head in front this legendary compiler suite. Its a classic. <span style="color:#000000;">I tried a lot, but my heart won&#8217;t allow me to switch to the new generation Visual Studio IDEs. Still 6.0 is my favorite. What about you guys? Comment on!<br />
</span></span></p>
<p><img class="alignnone size-medium wp-image-51" src="http://weseetips.files.wordpress.com/2008/03/beginnerseries.jpg?w=215" alt="" width="215" height="32" /><br />
Targeted Audience &#8211; Beginners.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/07/15/interesting-bug-in-visualstudio/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Copy-Paste of source files; Compilation Guard Band&#039;s worst enemy.</title>
		<link>http://weseetips.com/2008/05/10/copy-paste-of-source-files-compilation-guard-bands-worst-enemy/</link>
		<comments>http://weseetips.com/2008/05/10/copy-paste-of-source-files-compilation-guard-bands-worst-enemy/#comments</comments>
		<pubDate>Sat, 10 May 2008 19:01:05 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Glorious Bugs]]></category>
		<category><![CDATA[Compilation Guard Band]]></category>
		<category><![CDATA[error C2065]]></category>
		<category><![CDATA[hard bug]]></category>
		<category><![CDATA[undeclared identifier]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=107</guid>
		<description><![CDATA[In big projects, sometimes you want to write almost similar classes, which is more or less similar. For instance, assume you have a request base class, and the derived classes should implement some common virtual functions. Usually one easy method is to copy-paste one of the existing derived class so that by making minor change, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
In big projects, sometimes you want to write almost similar classes, which is more or less similar. For instance, assume you have a request base class, and the derived classes should implement some common virtual functions.</p>
<p>Usually one easy method is to copy-paste one of the existing derived class so that by making minor change, we can start the next derived class. While doing so, just remember &#8211; you are making one of the dangerous, hard to detect bug. When you try to compile your source, the second derived class you created, will show the error </p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/05/10/copy-paste-of-source-files-compilation-guard-bands-worst-enemy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

