<?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; Windows Shell Pearls</title>
	<atom:link href="http://weseetips.com/category/windows-shell-pearls/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>How to empty recycle bin programmatically?</title>
		<link>http://weseetips.com/2008/06/21/how-to-empty-recycle-bin-programmatically/</link>
		<comments>http://weseetips.com/2008/06/21/how-to-empty-recycle-bin-programmatically/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 18:27:25 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Windows Shell Pearls]]></category>
		<category><![CDATA[clear recycle bin]]></category>
		<category><![CDATA[empty recycle bin]]></category>
		<category><![CDATA[recycle bin]]></category>
		<category><![CDATA[SHEmptyRecycleBin]]></category>
		<category><![CDATA[SHERB_NOCONFIRMATION]]></category>
		<category><![CDATA[SHERB_NOPROGRESSUI]]></category>
		<category><![CDATA[SHERB_NOSOUND]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=182</guid>
		<description><![CDATA[While processing or writing huge files to disk, its quite possible that disk will go out of space. To Squeeze and to get more disk space, its a good idea to clean the recycle bin. But how to do it programmatically? You can use the api &#8211; SHEmptyRecycleBin(). See the code snippet below. // Empty [...]]]></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 />
While processing or writing huge files to disk, its quite possible that<span style="color:#0000ff;"> disk will go out of space.</span> To Squeeze and <span style="color:#0000ff;">to get more disk space</span>, <span style="color:#0000ff;">its a good idea to clean the recycle bin</span>. But how to do it programmatically?</p>
<p><img class="alignnone size-medium wp-image-12" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
You can use the api &#8211; <span style="color:#0000ff;">SHEmptyRecycleBin()</span>. See the code snippet below.</p>
<pre>// Empty the recycle bin.
SHEmptyRecycleBin( NULL,
                   NULL,
                   SHERB_NOCONFIRMATION |
                   SHERB_NOPROGRESSUI   |
                   SHERB_NOSOUND );</pre>
<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 />
By modifying the options, you can show progress UI, Show confirmation dialog and play sound on finishing task. Just remove the unwanted flags.</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/06/21/how-to-empty-recycle-bin-programmatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the icon of a file?</title>
		<link>http://weseetips.com/2008/06/03/how-to-get-the-icon-of-a-file/</link>
		<comments>http://weseetips.com/2008/06/03/how-to-get-the-icon-of-a-file/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 18:58:57 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Windows Shell Pearls]]></category>
		<category><![CDATA[file icon]]></category>
		<category><![CDATA[how to get file icon]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[SHGetFileInfo()]]></category>
		<category><![CDATA[SHGFI_ICON]]></category>
		<category><![CDATA[SHGFI_ICONLOCATION]]></category>
		<category><![CDATA[SHGFI_LARGEICON]]></category>
		<category><![CDATA[SHGFI_SMALLICON]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=153</guid>
		<description><![CDATA[If you try to delete files in Vista, you can see the following dialog. Did you noticed that, for every file, it will display its corresponding file icon. That&#8217;s pretty nice thing. If you are writing your own file browser tree or list, it will be nice to display the files with their own icons. [...]]]></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 />
If you try to delete files in Vista, you can see the following dialog.</p>
<p><img class="alignnone size-medium wp-image-154" src="http://siteground205.com/~weseetip/wp-content/uploads/2008/06/fileicon_messagebox.jpg?w=300" alt="" width="300" height="148" /></p>
<p>Did you noticed that, for every file, it will display its <span style="color:#0000ff;">corresponding file icon</span>. That&#8217;s pretty nice thing. If you are writing your own file browser tree or list, it will be nice to display the files with their own icons. But how can you get the file icon of a file?</p>
<p><img class="alignnone size-medium wp-image-12" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
You can use the call &#8211; <span style="color:#0000ff;">SHGetFileInfo()</span>. While calling the function, pass <span style="color:#0000ff;">SHGFI_ICON</span> as parameter. It will return handle for File icon. See the following code snippet.</p>
<pre>// The classic FooBar. <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />
CString FilePath = _T("C:\\FooBar.zip");

// Get the file icon.
SHFILEINFO FileInfo = { 0 };
SHGetFileInfo( FilePath,
               0,
               &amp;FileInfo,
               sizeof( FileInfo ),
               SHGFI_ICON );

// FileInfo.hIcon contains Icon handle.</pre>
<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 />
There are more constants such as &#8211; <span style="color:#0000ff;">SHGFI_ICONLOCATION</span>, <span style="color:#0000ff;">SHGFI_LARGEICON</span>, <span style="color:#0000ff;">SHGFI_SMALLICON</span> etc. Seems they are self explanatory. <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" src="http://weseetips.files.wordpress.com/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audience &#8211; Intermediate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/06/03/how-to-get-the-icon-of-a-file/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to get the path of Special Folders in windows.</title>
		<link>http://weseetips.com/2008/05/01/how-to-get-the-path-of-special-folders-in-windows/</link>
		<comments>http://weseetips.com/2008/05/01/how-to-get-the-path-of-special-folders-in-windows/#comments</comments>
		<pubDate>Thu, 01 May 2008 18:58:38 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Windows Shell Pearls]]></category>
		<category><![CDATA[CSIDL]]></category>
		<category><![CDATA[path of special folders]]></category>
		<category><![CDATA[SHGetSpecialFolderPath]]></category>
		<category><![CDATA[special folders]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=90</guid>
		<description><![CDATA[Windows have a number of special folder such as my documents, desktop folder etc. They are special because, their path can be different in system to system. So how can you get the path of special folder in windows? You can use the api &#8211; SHGetSpecialFolderPath(). For each special folder there is a predefined ID [...]]]></description>
			<content:encoded><![CDATA[<p><a href="None"></a></p>
<p><a href="None"></a><img class="alignnone size-medium wp-image-11" src="http://weseetips.wordpress.com/files/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
Windows have a number of special folder such as my documents, desktop folder etc. They are special because, their path can be different in system to system. So how can you get the path of special folder in windows?</p>
<p><img class="alignnone size-medium wp-image-12" src="http://weseetips.wordpress.com/files/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
You can use the api &#8211; <span style="color:#0000ff;">SHGetSpecialFolderPath()</span>. For each special folder there is a predefined ID called <span style="color:#0000ff;">CSIDL</span>. For instance, <span style="color:#0000ff;">for windows system directory</span> the CSIDL is <span style="color:#0000ff;">CSIDL_WINDOWS</span>. While calling the function, you&#8217;ve to provide the string buffer and the CSIDL and the requested special folder path is retuned in specified string buffer. See code snippet which fetches the path of Desktop directory.</p>
<pre>// String buffer for holding the path.
TCHAR strPath[ MAX_PATH ];

// Get the special folder path.
SHGetSpecialFolderPath(
    0,       // Hwnd
    strPath, // String buffer.
    CSIDL_DESKTOPDIRECTORY, // CSLID of folder
    FALSE ); // Create if doesn't exists?</pre>
<p><img class="alignnone size-medium wp-image-18" src="http://weseetips.wordpress.com/files/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Wanna to see the list of CSLID of special folders? have a look at them. Their names are self explanatory.</p>
<p>CSIDL_ADMINTOOLS<br />
CSIDL_ALTSTARTUP<br />
CSIDL_APPDATA<br />
CSIDL_BITBUCKET<br />
CSIDL_COMMON_ADMINTOOLS<br />
CSIDL_COMMON_ALTSTARTUP<br />
CSIDL_COMMON_APPDATA<br />
CSIDL_COMMON_DESKTOPDIRECTORY<br />
CSIDL_COMMON_DOCUMENTS<br />
CSIDL_COMMON_FAVORITES<br />
CSIDL_COMMON_PROGRAMS<br />
CSIDL_COMMON_STARTMENU<br />
CSIDL_COMMON_STARTUP<br />
CSIDL_COMMON_TEMPLATES<br />
CSIDL_CONTROLS<br />
CSIDL_COOKIES<br />
CSIDL_DESKTOP<br />
CSIDL_DESKTOPDIRECTORY<br />
CSIDL_DRIVES<br />
CSIDL_FAVORITES<br />
CSIDL_FONTS<br />
CSIDL_HISTORY<br />
CSIDL_INTERNET<br />
CSIDL_INTERNET_CACHE<br />
CSIDL_LOCAL_APPDATA<br />
CSIDL_MYMUSIC<br />
CSIDL_MYPICTURES<br />
CSIDL_NETHOOD<br />
CSIDL_NETWORK<br />
CSIDL_PERSONAL<br />
CSIDL_PRINTERS<br />
CSIDL_PRINTHOOD<br />
CSIDL_PROFILE<br />
CSIDL_PROGRAM_FILES<br />
CSIDL_PROGRAM_FILES_COMMON<br />
CSIDL_PROGRAMS<br />
CSIDL_RECENT<br />
CSIDL_SENDTO<br />
CSIDL_STARTMENU<br />
CSIDL_STARTUP<br />
CSIDL_SYSTEM<br />
CSIDL_TEMPLATES<br />
CSIDL_WINDOWS</p>
<p><img class="alignnone size-medium wp-image-51" src="http://weseetips.wordpress.com/files/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/05/01/how-to-get-the-path-of-special-folders-in-windows/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to change the desktop wallpaper, programmatically.</title>
		<link>http://weseetips.com/2008/04/27/how-to-change-the-desktop-wallpaper-programmatically/</link>
		<comments>http://weseetips.com/2008/04/27/how-to-change-the-desktop-wallpaper-programmatically/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 09:10:18 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Windows Shell Pearls]]></category>
		<category><![CDATA['IActiveDesktop' : undeclared identifier]]></category>
		<category><![CDATA[ApplyChanges]]></category>
		<category><![CDATA[change wallpaper]]></category>
		<category><![CDATA[IActiveDesktop]]></category>
		<category><![CDATA[SetWallpaper]]></category>
		<category><![CDATA[Windows shell]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=86</guid>
		<description><![CDATA[I bet at least once in your lifetime, you&#8217;ve used desktop wallpaper changing applications like webshots - which sets beautiful wallpaper to the desktop automatically after certain time intervals. When i started leaning windows programming, i wonder &#8211; how this application changes the wallpaper. The answer is &#8211; IActiveDesktop. The IActiveDesktop is a com interface [...]]]></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 />
I bet at least once in your lifetime, you&#8217;ve used desktop wallpaper changing applications like <strong>webshots </strong>- which sets beautiful wallpaper to the desktop automatically after certain time intervals. When i started leaning windows programming, i wonder &#8211; how this application changes the wallpaper. The answer is &#8211; <span style="color:#0000ff;">IActiveDesktop</span>.</p>
<p><img class="alignnone size-medium wp-image-12" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
The <span style="color:#0000ff;">IActiveDesktop</span> is a com interface exposed by windows shell. You&#8217;ve to call the <span style="color:#0000ff;">SetWallpaper()</span> function and then apply the changes by calling <span style="color:#0000ff;">ApplyChanges()</span>. See the code snippet below.</p>
<pre>#include "shlobj.h"
...

HRESULT hr;
IActiveDesktop* pActiveDesktop = 0;

// Initialize COM.
::CoInitialize( 0 );

// Get the ActiveDesktop Interface.
hr = CoCreateInstance( CLSID_ActiveDesktop,
                       0,
                       CLSCTX_INPROC_SERVER,
                       IID_IActiveDesktop,
                       (void**) &amp;pActiveDesktop );

// Check whether CoCreateInstance is success.
if( FAILED( hr ))
{
    // Creating ActiveDesktop interface pointer failed.
    AfxMessageBox( _T("Error Occurred!"));
}

// SetWallpaper() accepts the wallpaper path only as WideChar.
LPCWSTR strWallPaper = L"C:\\Autumn Leaves.jpg";

// Set the new wallpaper.
pActiveDesktop-&gt;SetWallpaper( strWallPaper, 0 );

// Apply changes to refresh desktop.
pActiveDesktop-&gt;ApplyChanges( AD_APPLY_ALL );

// Release the interface pointer.
pActiveDesktop-&gt;Release();

// Uninitialize COM.
::CoUninitialize();</pre>
<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 />
While compiling this, certainly you will hit the following error.</p>
<pre>error C2065: 'IActiveDesktop' : undeclared identifier
error C2065: 'pActiveDesktop' : undeclared identifier
error C2106: '=' : left operand must be l-value</pre>
<p>Don&#8217;t worry. Its a known issue. For solving this error, take StdAfx.h and include <span style="color:#0000ff;">wininet.h</span> header just before <span style="color:#0000ff;">afxdisp.h</span>. I assume you&#8217;re using MFC. See the sample below.</p>
<pre>#include &lt;afxwin.h&gt;
#include &lt;afxext.h&gt;
<span style="color:#0000ff;">#include "wininet.h"</span>
#include &lt;afxdisp.h&gt;
#include &lt;afxdtctl.h&gt;</pre>
<p>Keen to know more? See <span style="color:#0000ff;"><a title="Microsoft Knowledge Base Article" href="http://support.microsoft.com/kb/196342" target="_blank">KB196342</a></span> for more details.</p>
<p><img class="alignnone size-medium wp-image-53" src="http://weseetips.files.wordpress.com/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Trargeted Audience &#8211; Intermediate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/04/27/how-to-change-the-desktop-wallpaper-programmatically/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

