<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://windowsteamblog.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>Windows 7 for Developers : Sample Code</title><link>http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx</link><description>Tags: Sample Code</description><dc:language>en</dc:language><generator>CommunityServer 2008 SP1 (Build: 30619.63)</generator><item><title>Fishbowl for Facebook Using the Windows 7 Taskbar for Extra Spice</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/11/19/fishbowl-for-facebook-using-the-windows-7-taskbar-for-extra-spice.aspx</link><pubDate>Fri, 20 Nov 2009 01:41:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:529030</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=529030</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/11/19/fishbowl-for-facebook-using-the-windows-7-taskbar-for-extra-spice.aspx#comments</comments><description>&lt;p&gt;During Wednesday&amp;rsquo;s keynote, Brian Goldfarb demoed an amazing&amp;nbsp;Silverlight 4 client for Facebook. Beyond its amazing looks,&amp;nbsp;this Silverlight 4&amp;nbsp;demo&amp;nbsp;provides a full and complete desktop client application for Windows (and Mac). SilverFace is built on top of Silverlight 4 &amp;ndash; also announced during the keynote. If you want a cool Facebook client application to work on from your Windows desktop, you should take a look&amp;nbsp;at the&amp;nbsp;&lt;a href="http://www.fishbowlclient.com/"&gt;&lt;strong&gt;Fishbowl for Facebook Preview&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;. &lt;/strong&gt;Fishbowl is a great WPF application that you can install and enjoy as a user, and at the same time it is a&amp;nbsp;great code sample for developers whom are looking to write&amp;nbsp;WPF applications that use Windows 7 features.&amp;nbsp; If you are interested, you can &lt;a href="http://fishbowl.codeplex.com/"&gt;download the source code for Fishbowl&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In today's world, the client&amp;rsquo;s experience is more important than ever before. Your application doesn&amp;rsquo;t just have to be fun and interesting; it has to be good looking, polished, and functional, providing a &amp;ldquo;natural&amp;rdquo; user experience that just works. As a developer, you need to push the envelope and use any available technical tool that the OS provides or any other available means (if installed on mobile devices) to provide a superior user experience, or users will switch to the next guy. In such a competitive scenario, using the Windows 7 Taskbar to shave a few seconds from day-to-day tasks looks like a very obvious choice.&lt;/p&gt;
&lt;p&gt;Both Silverlight 4 demo and Fishbowl applications each provide a great UX and enhance user productivity. Scott Guthrie also announced the &lt;a href="http://msdn.microsoft.com/en-us/windows/ee388574.aspx"&gt;Facebook SDK&lt;/a&gt; for managed code applications that combines the latest in Web and Client platform innovations with leading Social technologies (services) to help developers plug into Facebook. But, beside the new Facebook SDK and beside the great looks, the Fishbowl application is a great WPF (3.5) example that demonstrates how to write applications that produce amazing experiences on Windows 7.&lt;/p&gt;
&lt;p&gt;As a WPF application, Fishbowl runs on multiple Windows versions, including Windows XP, Windows Vista, and Windows 7, and it integrates with the Windows 7 Taskbar and Multitouch. One of the main ideas behind the Taskbar is to provide users with quick and easy access to their content and help them accomplish tasks and navigate between windows easier and with more confidence. For example, JumpList provides a great tool for surfacing common work items and tasks. If you have a task that you perform once or twice a day, taking two or three clicks to perform the task is not that bad. However, if you have a task that you perform 10, 20, or even 30 more times, using JumpList tasks or items in the recent category list goes a long way. Facebook users often check their wall, write notifications and messages, view friends' pictures, and so on. Therefore, in some scenarios, the Taskbar JumpList tasks, icon notification, thumbnail buttons, and other functionality become major tools in the application. &lt;/p&gt;
&lt;p&gt;Fishbowl uses the taskbar to provide a quick, easy, and seamless integration with Facebook functionality directly from your Taskbar. Let&amp;rsquo;s review some of the user functionality before jumping into code behind. &lt;/p&gt;
&lt;table width="551" cellpadding="2" cellspacing="0" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="265" valign="top"&gt;The Fishbowl taskbar offers a few tasks even before you start your application. You can go to Facebook.com, or you can actually &amp;ldquo;jump&amp;rdquo; directly and see your wall, friend's picture, and more, as the following image shows. &lt;br /&gt;One of the amazing things in Fishbowl for Facebook is that it changes it functionality between the different modes of the application. Being able to use the taskbar differently for&lt;/td&gt;
&lt;td width="284" valign="top"&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/TaskbarBeforeStart_5F00_119ECE9E.png"&gt;&lt;img height="229" width="240" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/TaskbarBeforeStart_5F00_thumb_5F00_57AF8BB1.png" alt="TaskbarBeforeStart" border="0" title="TaskbarBeforeStart" style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;different scenarios provides an amazing user experience in heavily used application like Fishbowl.&lt;/p&gt;
&lt;p&gt;When Fishbowl runs in normal mode, the Taskbar JumpList reflects items and tasks that you can actually perform in the context of a running application, like viewing the last few notifications and messages that you received without opening the application, as shown by the following image.&lt;/p&gt;
&lt;table width="551" cellpadding="2" cellspacing="0" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="225" valign="top"&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/TaskbarAfterStart_5F00_6C052B6F.png"&gt;&lt;img height="265" width="164" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/TaskbarAfterStart_5F00_thumb_5F00_191A183E.png" alt="TaskbarAfterStart" border="0" title="TaskbarAfterStart" style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" /&gt;&lt;/a&gt; &lt;/td&gt;
&lt;td width="324" valign="top"&gt;If you hover with the mouse above the Fishbowl control, you see the thumbnail preview provided by Windows 7 taskbar. However, Fishbowl uses the thumbnail button again allowing you to both view a preview of the application and act immediately upon the thumbnail preview as shown in the following image.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;If you hover with the mouse above the Fishbowl control, you see the thumbnail preview provided by Windows 7 taskbar. However, Fishbowl uses the thumbnail button again allowing you to both view a preview of the application and act immediately upon the thumbnail preview as shown in the following image.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/thumbnailbutton_5F00_1CB8331B.png"&gt;&lt;img height="445" width="472" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/thumbnailbutton_5F00_thumb_5F00_1E58D922.png" alt="thumbnail button" border="0" title="thumbnail button" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;(And thank you Raman for writing so many PDC tweets J)&lt;/p&gt;
&lt;p&gt;Fishbowl also has a mini-mode operation mode. This mode shows just one message in a small window. As you can see in the following image, a small arrow allows you to switch between messages. When you hover over Fishbowl taskbar icon, you can see the preview but you can also control the message, again using the taskbar thumbnail preview.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/minimode_5F00_7A7001C7.png"&gt;&lt;img height="447" width="545" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/minimode_5F00_thumb_5F00_36D850A5.png" alt="minimode" border="0" title="minimode" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Besides great Taskbar integration, Fishbowl offers a great Multitouch experience, allowing you to scroll between messages using your finger to touch the touch screen. It is a little hard to illustrate Multitouch with screen capture so you will have to trust me on this one. &lt;/p&gt;
&lt;p&gt;We've covered most of the Fishbowl features unique to Windows 7, and in the next post I will dive into the API that enabled these Taskbar and Multitouch features. If you are interested, you can &lt;a href="http://fishbowl.codeplex.com/"&gt;download the source code for Fishbowl&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=529030" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows/default.aspx">Windows</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Multi-Touch/default.aspx">Multi-Touch</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/PDC09/default.aspx">PDC09</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/PDC2009/default.aspx">PDC2009</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+API+Code+Pack/default.aspx">Windows API Code Pack</category></item><item><title>New Windows API Code Pack Version</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/11/18/new-windows-api-code-pack-version.aspx</link><pubDate>Thu, 19 Nov 2009 00:02:42 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:528968</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=528968</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/11/18/new-windows-api-code-pack-version.aspx#comments</comments><description>&lt;p&gt;I am glad to announce that today we shipped a new version of the &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;Windows API Code Pack&lt;/a&gt; – version 1.0.1. This is not a major version with a lot of new features, but rather a minor version focused on fixing bugs, improving performance, adding demos and few features updates (new wrappers…) &lt;/p&gt;  &lt;p&gt;But before we dive into this new version of the Windows Code Pack let’s better understand what this Windows API Code Pack is all about. &lt;/p&gt;  &lt;p&gt;Windows 7 offers new features like the taskbar, libraries, and the Sensor and Location platform, to name a few. These features enable new scenarios and create new opportunities for developers to make their applications shine on Windows 7. All these great features are exposed via the Win32 native API. Currently there is no “Windows 7” namespace in the .NET Framework, and no easy way to use these features from managed code applications. To help managed code developers access them, we released version 1.0 of the Windows API Code Pack for the .NET Framework in August (just after Windows 7 RTM). &lt;/p&gt;  &lt;p&gt;The Windows API Code Pack &lt;b&gt;is&lt;/b&gt; a &lt;b&gt;free&lt;/b&gt;, managed&lt;b&gt; Source Code Library &lt;/b&gt;provided by Microsoft &lt;b&gt;as is&lt;/b&gt;. You should consider this library as if &lt;b&gt;you wrote it yourself&lt;/b&gt;, as if it &lt;b&gt;is your own code&lt;/b&gt;. It is a great starting point and provides a really good and solid solution for managed code developers. It covers a lot of the new Windows 7 features as well as some more fundamental core features from the Windows Vista timeframe. You may think of the Windows API Code Pack as the closest thing to an “official” managed API for Windows. But you need to remember that it’s not a product with 24x7 technical support available from Microsoft Customer Service and Support. We believe it is a great solution, and that the codebase is very solid and high quality. &lt;/p&gt;  &lt;p&gt;Our goal with the code pack is to enable managed code developers to take advantage of Windows APIs that are not part of the .NET Framework. We feel that as a shared source that is separate from the .NET runtime libraries, the Windows API Code Pack provides an optimal compromise between the Microsoft Win32 managed wrapper, short time-to-market -we released the Windows API Code Pack just a month after the Win7 RTM, and we ship full source code of the library.&lt;/p&gt;  &lt;p&gt;The Windows API Code Pack includes a great deal of managed API for Windows (7). For example:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Extensive integration with the Windows Shell namespace, with support for the Windows Shell property system, providing control like explorer browser and access to Windows Libraries &lt;/li&gt;    &lt;li&gt;A completely 100% feature parity with the native Taskbar API including (but not limited to) JumpLists, Icon Overlay, Progress bar, Thumbnail, custom switcher, Thumbnail Button, etc… &lt;/li&gt;    &lt;li&gt;Windows Task Dialogs , other controls &lt;/li&gt;    &lt;li&gt;Support for Direct3D 11.0 and DXGI 1.0/1.1 APIs &lt;/li&gt;    &lt;li&gt;Support for the Sensor Platform APIs &lt;/li&gt;    &lt;li&gt;Extended Linguistic Services APIs &lt;/li&gt;    &lt;li&gt;Windows Restart Manager &lt;/li&gt;    &lt;li&gt;Power APIs &lt;/li&gt;    &lt;li&gt;And many other features &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Each technology represented in the Windows API Code Pack has multiple demos and examples (including source) in C# and VB. We are planning on releasing updates to the Windows API Code Pack roughly every three months. We will be investing mainly in stability (meaning fixing bugs), fundamentals, testing and documentation, as well as new feature support (based on customer feedback).&lt;/p&gt;  &lt;p&gt;You may ask yourself, “&lt;b&gt;Why isn't the Windows API Code Pack part of the .NET Framework?&lt;/b&gt;” &lt;/p&gt;  &lt;p&gt;We ship open source code that we might bring into the runtime sometime in the future, if we feel it's sufficiently core to the entire framework to be worth the size increase. Remember the .NET Framework runs on both Windows Vista and Windows XP. However, Windows 7 is here now, and we want to enable you to access this set of free, open source library sooner rather than later. We’re shipping this library in a community-supported form and, as you can see, we intend to keep updating it. While this version (1.0.1) is a minor release, we are planning on another release in the next few months. In the meantime, you get the best of both worlds in a package that you can use as a whole or in parts without restriction.&lt;/p&gt;  &lt;p&gt;Another question you may ask is, “&lt;b&gt;Will .NET 4 replace the need to use the Windows API Code pack&lt;/b&gt;?”&lt;/p&gt;  &lt;p&gt;When .NET 4 ships, you will be able to use its Windows 7 features such as Taskbar and multitouch integration with WPF, DirectWrite support, and the location API via the Devices namespace. Continue to access other features such as libraries, Restart Manager, and Sensors via the Windows API Code Pack. &lt;/p&gt;  &lt;p&gt;Last but not least, we are looking for feedback from the community – that is you the .NET developer using this library to write managed code applications for Windows 7. On the &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;Windows API Code Pack site&lt;/a&gt;, you can ask questions, provide feedback, report bugs, and follow open bugs. Your input is critical for the continuation of this library, so please send us your feedback and questions. &lt;/p&gt;  &lt;p&gt;To learn more about how to use the Windows API Code Pack check the &lt;a href="http://channel9.msdn.com/learn/courses/Windows7/" target="_blank"&gt;Windows 7 Training on Channel 9&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=528968" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows/default.aspx">Windows</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sensor+and+Location/default.aspx">Sensor and Location</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Libraries/default.aspx">Libraries</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+API+Code+Pack/default.aspx">Windows API Code Pack</category></item><item><title>Windows 7 RTM – Go Get It</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/08/06/windows-7-rtm-go-get-it.aspx</link><pubDate>Thu, 06 Aug 2009 22:36:48 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:522353</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>42</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=522353</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/08/06/windows-7-rtm-go-get-it.aspx#comments</comments><description>&lt;p&gt;This is it people. Windows 7 RTM is available for download from &lt;a href="http://msdn.microsoft.com"&gt;MSDN&lt;/a&gt; &amp;amp; &lt;a href="http://technet.microsoft.com"&gt;TechNet&lt;/a&gt; sites! If you have a MSDN subscription you can get Windows 7 RTM in English. On October 1st, the remaining languages will be released, for more information read - &lt;a href="http://windowsteamblog.com/blogs/windows7/archive/2009/08/06/windows-7-rtm-available-today-for-msdn-amp-technet-subscribers.aspx"&gt;Windows 7 RTM Available Today for MSDN &amp;amp; TechNet Subscribers&lt;/a&gt;. You can also get the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=71deb800-c591-4f97-a900-bea146e4fae1&amp;amp;displaylang=en" target="_blank"&gt;Windows 7 SDK&lt;/a&gt;&amp;#160; and the RTM version of the &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;Windows API Code Pack for .NET Framework&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Make sure you get them all today to start testing your applications, and to make sure &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/07/23/is-your-application-ready-for-windows-7-rtm.aspx"&gt;your applications are ready for Windows 7 RTM&lt;/a&gt;! Now is the time to work on your applications to make sure they are Windows 7 compatible. On top of that, you can use new Windows 7 features such as the Sensor and Location Platform, Taskbar, Libraries, Multi-Touch, the new Graphics APIs, the Windows Ribbon, and many other important and exciting Windows 7 technologies to make your application shine on Windows 7.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;New Windows 7 Training Kit for Developers - Get it NOW!&lt;/strong&gt;&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="20" width="580"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="206"&gt;To help you get your application on Windows 7 as soon as possible, we updated the &lt;strong&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1c333f06-fadb-4d93-9c80-402621c600e7&amp;amp;displaylang=en" target="_blank"&gt;Windows 7 Training Kit for Developers&lt;/a&gt;&lt;/strong&gt; for the RTM version and gave it a new look and better functionality. You can still find all existing topics such as: Taskbar, Sensor and Location, Libraries and Shell, DirectX, Multi-touch, Ribbon, etc. No dev was left behind! The kit is built for both native Win32 &lt;/td&gt;        &lt;td valign="top" width="374"&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1c333f06-fadb-4d93-9c80-402621c600e7&amp;amp;displaylang=en"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="Windows7TrainingKit" border="0" alt="Windows7TrainingKit" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/Windows7TrainingKit_5F00_18500CB9.png" width="389" height="314" /&gt;&lt;/a&gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;C++ developers and .NET developers, so now most topics have multiple labs.We also added 6 new Application Compatibility labs: Version Checking, Data Redirection, UIPI, Installer Detection, Session 0 Isolation, and High DPI, to help you get over the most common application compatibility issues. All the topics in the training kit include additional information like whitepapers, links to MSDN, and links to &lt;strong&gt;videos from Channel 9&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;strong&gt;Updated Windows Topic Area on Channel 9&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;We also gave the &lt;a href="http://channel9.msdn.com/windows/"&gt;Windows topic area on Channel 9&lt;/a&gt; a brand new look and functionality to help you to better choose the right Windows 7 content you need. In the new Windows topic area for Channel 9, you can choose from three main topic areas:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://channel9.msdn.com/windows/using/"&gt;Using Windows 7&lt;/a&gt; – Contains consumer- and user-related videos such as how to install Windows 7 and how to set up a home group network &lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/windows/programming/"&gt;Programming Windows 7&lt;/a&gt; – I don’t really need to explain what goes here, right? &lt;/li&gt;    &lt;li&gt;Last but not least, “&lt;a href="http://channel9.msdn.com/windows/under-the-hood/"&gt;Under the Hood&lt;/a&gt;” – Contains classics like the &lt;a href="http://channel9.msdn.com/shows/Going+Deep/Mark-Russinovich-Inside-Windows-7/"&gt;interview with Mark Russinovich&lt;/a&gt; on Windows 7 Internals. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/windows/"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="NewC9" border="0" alt="NewC9" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/NewC9_5F00_3189E47C.png" width="549" height="414" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;While we hope you find all this helpful, this is only the start! We are working on more new and exciting content that will be shipped in the following weeks, so stay tuned.&lt;/p&gt;  &lt;p&gt;In the meantime, here is some additional useful information:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The &lt;a href="http://msdn.microsoft.com/en-us/windows/default.aspx"&gt;Windows page&lt;/a&gt; on MSDN is the one-stop shop for Windows client developers &lt;/li&gt;    &lt;li&gt;At &lt;a href="http://msdn.microsoft.com/en-us/windows/dd433113.aspx"&gt;Develop for Windows 7&lt;/a&gt;, you can find all the information you need about specific technologies like Direct2D, Taskbar, Sensor and Location, Power Shell 2, Windows Ribbon, and many more &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/windows/dd433113.aspx"&gt;Windows Application Compatibility&lt;/a&gt; is the one page you want to visit to make sure your application runs properly on Windows 7; it includes content and tools to test and fix many application compatibility issues. Directly accessible from that page, is the &lt;a href="http://msdn.microsoft.com/library/dd371778(VS.85).aspx"&gt;Windows 7 Application Quality Cookbook&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Also still very relevant, is the &lt;a href="http://msdn.microsoft.com/en-us/library/bb757005.aspx"&gt;Windows Vista Application Compatibility Cookbook&lt;/a&gt;--most Windows 7 compatibility issues are the direct result of the changes introduced in the Windows Vista timeframe, and are included as topics in this Cookbook (UAC, Session 0 Service Isolation, IE Protected Mode, etc.), which is a great starting point for addressing these issues &lt;/li&gt;    &lt;li&gt;New Windows 7 videos on the &lt;a href="http://channel9.msdn.com/windows"&gt;Channel 9 Windows &lt;/a&gt;page explore specific features and technologies, and are great “windows” to the Windows engineering team &lt;/li&gt;    &lt;li&gt;As always, the &lt;a href="http://blogs.msdn.com/e7"&gt;E7 blog&lt;/a&gt; is an amazing source of the engineering back story behind Windows 7 &lt;/li&gt;    &lt;li&gt;Last, but not least, for IT-Pro, we have our &lt;a href="http://technet.microsoft.com/en-us/windows/dd361745.aspx"&gt;SPRINGBOARD SERIES&lt;/a&gt;, and &lt;a href="http://edge.technet.com/windows/" target="_blank"&gt;edge on TechNet&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;And, of course, continue to watch for new posts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=522353" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7+Application+Compatibility/default.aspx">Windows 7 Application Compatibility</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Channel+9/default.aspx">Channel 9</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Labs/default.aspx">Labs</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7+Training+Kit/default.aspx">Windows 7 Training Kit</category></item><item><title>Version Checking (Just Don’t Do It)</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/08/05/version-checking-just-don-t-do-it.aspx</link><pubDate>Wed, 05 Aug 2009 22:55:33 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:522166</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>17</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=522166</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/08/05/version-checking-just-don-t-do-it.aspx#comments</comments><description>&lt;p&gt;Version checking is probably one of the most common Application Compatibility issues that both developers and users are facing. This is another post in a series of posts about &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/07/23/is-your-application-ready-for-windows-7-rtm.aspx" target="_blank"&gt;Getting Ready for Windows 7&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;As said, this is probably the most common application compatibility issue that users as well as developers face is when an application fails upon checking the operating system version. A lot can go wrong when version checking is misused. A user might experience a “silent fail” where the application simply fails to load and nothing happens. Or, a user might see a dialog box indicating something to the effect of “you must be running Microsoft Windows XP or later” when in fact, the computer is running Windows 7. Many other consequences to poor version checking can inconvenience users as well. &lt;/p&gt;  &lt;p&gt;Applications fail due to version checking for two main reasons:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;A flaw (bug) in the version checking code, which fails if the minor version is decreased, even if the major version is increased, for example, changing versions from 5.1(Windows XP) to 6.0 (Windows Vista), or if the expected service pack (SP) is not installed, even if you're running a newer operating system (for example, changing versions from Windows XP SP 2 to Windows Vista SP 1). We recommend that you check functionality rather then checking version, as you can read in this post. &lt;/li&gt;    &lt;li&gt;An intentional blocking that prevents the application from running on operating system versions not tested by its developers. We recommend that you &lt;strong&gt;do not &lt;/strong&gt;block applications from running on future operating systems. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;When an application runs on an &amp;quot;incompatible&amp;quot; (due to poor version checking) version of Windows, it will generally display an error message, but it may also exit silently or behave erratically. Often, if we work around the version checking, the application will run well. End-users and IT professionals may apply a fix to let the application think it is running on an older version of Windows.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Working Around The Problem (not really solving the bug)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Compatibility mode:&lt;/b&gt; Designed for &lt;strong&gt;end users&lt;/strong&gt; (not for developers to not fix their bugs), compatibility mode is an easy way to work around compatibility issues. When enabled, it applies a set of compatibility fixes that provide a runtime environment more compatible with applications written for older versions of Windows. One of those fixes is the &amp;quot;version lie,&amp;quot; which makes the version query functions return the operating system version the user chose in the &lt;b&gt;Compatibility&lt;/b&gt; tab of the &lt;b&gt;Properties&lt;/b&gt; dialog box instead of the actual Windows version.&lt;/p&gt;  &lt;p&gt;To enable compatibility mode:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Right-click the executable or shortcut to the executable. &lt;/li&gt;    &lt;li&gt;Click &lt;b&gt;Properties&lt;/b&gt;. &lt;/li&gt;    &lt;li&gt;Click the &lt;b&gt;Compatibility&lt;/b&gt; tab. &lt;/li&gt;    &lt;li&gt;Enable &lt;b&gt;Run this program in compatibility mode for:&lt;/b&gt; and select the operating system version you think the application should be able to run on.       &lt;br /&gt;Some applications consist of several executables. You may need to apply this fix to each one. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_14A7A765.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_53992800.png" width="251" height="341" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Click OK to close the dialog box. &lt;/li&gt;    &lt;li&gt;Run the application. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Checking for Features Rather Than Version&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As mentioned previously, checking the operating system version is not the best way to confirm that a specific operating system feature is available. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, it is more effective to test for the presence of the feature itself. For example, we plan to make the Direct2D and DirectWrite APIs and the Ribbon API available in Windows Vista, so there is no need to block your application from using these APIs when running on Windows Vista. You just need to check if these features are available on the Operation System that you are running. If possible, your application should still run if the feature is unavailable, though with reduced functionality or performance.&lt;/p&gt;  &lt;p&gt;You can use one of the following techniques to find out if a specific features is available on the given OS.&lt;/p&gt;  &lt;p&gt;For Win32 developers:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Use &lt;b&gt;LoadLibrary&lt;/b&gt;() to load a library which is not yet loaded into your application. If you are interested in a new function of a DLL which is already loaded (for example, kernel32.dll), then call &lt;b&gt;GetModuleHandle&lt;/b&gt;() to obtain the module handle. If either of these functions return NULL, then this indicates an error. &lt;/li&gt;    &lt;li&gt;Use &lt;b&gt;GetProcAddress&lt;/b&gt;() to obtain a function pointer. If &lt;b&gt;GetProcAddress()&lt;/b&gt; returns NULL, then the function may not exist. Cast the pointer to a function pointer of an appropriate prototype. Some functions, although they exist may actually be stubs that return a &amp;quot;not implemented&amp;quot; error. Be such to check for such errors. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Windows 7 introduces a new timer API - SetWaitableTimerEXProc, which adds one more input variable to the regular SetWaitableTimerProc. The TolerableDelay lets you specific a time tolerance window in which the timer can expire. This is a new in Windows 7, that we will use to demonstrate how to check for feature.&lt;/p&gt;  &lt;pre class="code"&gt;      &lt;span style="color: green"&gt;// define function pointer type
    &lt;/span&gt;&lt;span style="color: blue"&gt;typedef &lt;/span&gt;BOOL (WINAPI *SetWaitableTimerExProc)(
      __in  HANDLE hTimer,
      __in  &lt;span style="color: blue"&gt;const &lt;/span&gt;LARGE_INTEGER *lpDueTime,
      __in  LONG lPeriod,
      __in  PTIMERAPCROUTINE pfnCompletionRoutine,
      __in  LPVOID lpArgToCompletionRoutine,
      __in  PREASON_CONTEXT WakeContext,
      __in  ULONG TolerableDelay
    );

    LARGE_INTEGER liDueTime;
    liDueTime.QuadPart = 0;
    nt period = 1000;
    &lt;span style="color: blue"&gt;unsigned int &lt;/span&gt;tolerance = 1000;
    HANDLE hTimer = &lt;span style="color: green"&gt;// Get timer handle

    &lt;/span&gt;REASON_CONTEXT reasonContext = {0};
    reasonContext.Version = 0;
    reasonContext.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING;
    reasonContext.Reason.SimpleReasonString = L&lt;span style="color: #a31515"&gt;&amp;quot;MyTimer&amp;quot;&lt;/span&gt;;

    &lt;span style="color: green"&gt;// Get module handle to a module which is already loaded
    &lt;/span&gt;HMODULE hKernel32Module = GetModuleHandle(_T(&lt;span style="color: #a31515"&gt;&amp;quot;kernel32.dll&amp;quot;&lt;/span&gt;));
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(hKernel32Module == NULL)
        &lt;span style="color: blue"&gt;return &lt;/span&gt;FALSE;

    &lt;span style="color: green"&gt;// Get Address of function
    &lt;/span&gt;SetWaitableTimerExProc pFnSetWaitableTimerEx =
    (SetWaitableTimerExProc) ::GetProcAddress(hKernel32Module,     
        &lt;span style="color: #a31515"&gt;&amp;quot;SetWaitableTimerEx&amp;quot;&lt;/span&gt;);

    &lt;span style="color: green"&gt;// Check if the function exists    
    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(pFnSetWaitableTimerEx == NULL)
        &lt;span style="color: blue"&gt;return &lt;/span&gt;FALSE;

    &lt;span style="color: green"&gt;// Call function
    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(!pFnSetWaitableTimerEx(hTimer, &amp;amp;liDueTime, period, NULL, NULL,
            &amp;amp;reasonContext, tolerance)
    { &lt;span style="color: green"&gt;// handle error }

&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, you may use DLL delayed loading and call functions in a __try...__except block. (For more information, see &lt;a href="http://msdn.microsoft.com/en-us/library/151kt790.aspx"&gt;Linker Support for Delay-Loaded DLLs&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;For COM APIs, handle errors returned by &lt;b&gt;CoCreateInstance&lt;/b&gt; and &lt;b&gt;QueryInterface&lt;/b&gt;.NET framework applications that call Win32 APIs via &lt;b&gt;P/Invoke&lt;/b&gt; should handle &lt;b&gt;EntryPointNotFoundException&lt;/b&gt; and &lt;b&gt;DllNotFoundException&lt;/b&gt; exceptions.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If You Must Check OS Version Number&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Identifying the current operating system is not the best way to determine whether a particular operating system feature is present. However, if you can’t design your application to check for specific feature availability and the only way to ensure compatibility is through version checking, &lt;i&gt;then please consider the following&lt;/i&gt;.&lt;/p&gt;

&lt;p&gt;For native applications, you will need to ensure your application's logic will work with newer versions of Windows. Please &lt;strong&gt;DO NOT BLOCK &lt;/strong&gt;on version change! The following is a Win32 code example that uses &lt;b&gt;GetVersionEx&lt;/b&gt;. If the major version is greater than 5 (Windows Vista, Windows® Server 2008 R2 and Windows 7), the check passes. If it equals 5, then the minor version should be 1 or greater (Windows XP or Windows Server 2003).&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;#include &lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;lt;windows.h&amp;gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;#include &lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;lt;stdio.h&amp;gt;

&lt;/span&gt;&lt;span style="color: blue"&gt;void &lt;/span&gt;main()
{
    OSVERSIONINFO osvi;
    BOOL bIsWindowsXPorLater;

    ZeroMemory(&amp;amp;osvi, &lt;span style="color: blue"&gt;sizeof&lt;/span&gt;(OSVERSIONINFO));
    osvi.dwOSVersionInfoSize = &lt;span style="color: blue"&gt;sizeof&lt;/span&gt;(OSVERSIONINFO);

    GetVersionEx(&amp;amp;osvi);

    bIsWindowsXPorLater = 
 ( (osvi.dwMajorVersion &amp;gt; 5) ||
       ( (osvi.dwMajorVersion == 5) &amp;amp;&amp;amp; (osvi.dwMinorVersion &amp;gt;= 1) ));

    &lt;span style="color: blue"&gt;if&lt;/span&gt;(bIsWindowsXPorLater)
  printf(&lt;span style="color: #a31515"&gt;&amp;quot;The system meets the requirements.\n&amp;quot;&lt;/span&gt;);
    &lt;span style="color: blue"&gt;else &lt;/span&gt;printf(&lt;span style="color: #a31515"&gt;&amp;quot;The system does not meet the requirements.\n&amp;quot;&lt;/span&gt;);
}&lt;/pre&gt;

&lt;p&gt;However there is a better way to verify the minimum OS version required using &lt;a href="http://msdn.microsoft.com/en-us/library/ms725492(VS.85).aspx"&gt;VerifiyVersionInfo()&lt;/a&gt;. This function compares a set of operating system version requirements to the corresponding values for the currently running version of the system. The following code example uses &lt;b&gt;VerifyVersionInfo&lt;/b&gt; to check the operating system version against minimal requirements (Windows XP SP2):&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;#include &lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;lt;windows.h&amp;gt;
&lt;/span&gt;BOOL Is_WinXP_SP2_or_Later () 
{
   OSVERSIONINFOEX osvi;
   DWORDLONG dwlConditionMask = 0;
   &lt;span style="color: blue"&gt;int &lt;/span&gt;op=VER_GREATER_EQUAL;

   &lt;span style="color: green"&gt;// Initialize the OSVERSIONINFOEX structure.

   &lt;/span&gt;ZeroMemory(&amp;amp;osvi, &lt;span style="color: blue"&gt;sizeof&lt;/span&gt;(OSVERSIONINFOEX));
   osvi.dwOSVersionInfoSize = &lt;span style="color: blue"&gt;sizeof&lt;/span&gt;(OSVERSIONINFOEX);
   osvi.dwMajorVersion = 5;
   osvi.dwMinorVersion = 1;
   osvi.wServicePackMajor = 2;
   osvi.wServicePackMinor = 0;

   &lt;span style="color: green"&gt;// Initialize the condition mask.

   &lt;/span&gt;VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op );
   VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op );
   VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, op );
   VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR, op );

   &lt;span style="color: green"&gt;// Perform the test.

   &lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;VerifyVersionInfo(
      &amp;amp;osvi, 
      VER_MAJORVERSION | VER_MINORVERSION | 
      VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
      dwlConditionMask);
}&lt;/pre&gt;

&lt;p&gt;In this code you can see how we use the VerifyVersion with a set of conditions to return TRUE incase we run on any OS grater than Windows XP Service Pack 2.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;For .NET Framework developers, use the ==, !=, &amp;lt;=, &amp;lt;, &amp;gt;, &amp;gt;= operators of the &lt;b&gt;Version&lt;/b&gt; object returned by &lt;b&gt;Environment.OSVersion.Version&lt;/b&gt;:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: green"&gt;// This code checks if the OS is at least Windows XP
  &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(Environment.OSVersion.Version &amp;lt; &lt;span style="color: blue"&gt;new &lt;/span&gt;Version(5, 1))
  {
        MessageBox.Show(&lt;span style="color: #a31515"&gt;&amp;quot;Windows XP or later required.&amp;quot;&lt;/span&gt;,
         &lt;span style="color: #a31515"&gt;&amp;quot;Incompatible Operating System&amp;quot;&lt;/span&gt;, MessageBoxButtons.OK,
                MessageBoxIcon.Error);
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;
  }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;It is highly recommended that you don’t check for version at all and try looking to work with features. It will prove valuable for the future…&lt;/p&gt;

&lt;p&gt;Just incase you want to read more, here are some useful links&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Application Compatibility Cookbook: &lt;a href="http://msdn.microsoft.com/en-us/library/bb963893.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb963893.aspx&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;Version Lie and Managed Applications: &lt;a href="http://blogs.msdn.com/cjacks/archive/2007/09/10/version-lie-shims-and-managed-code-on-windows-vista.aspx"&gt;http://blogs.msdn.com/cjacks/archive/2007/09/10/version-lie-shims-and-managed-code-on-windows-vista.aspx&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also &lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers.CodeSamples.AppCompat/VersionCHecking.zip" target="_blank"&gt;download a HOL and code sample for this topic&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=522166" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7+Application+Compatibility/default.aspx">Windows 7 Application Compatibility</category></item><item><title>Developing for the Windows 7 Taskbar – Jump into Jump Lists – Part 3</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/07/02/developing-for-the-windows-7-taskbar-jump-into-jump-lists-part-3.aspx</link><pubDate>Thu, 02 Jul 2009 20:59:29 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:518119</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=518119</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/07/02/developing-for-the-windows-7-taskbar-jump-into-jump-lists-part-3.aspx#comments</comments><description>&lt;p&gt;So far, you have seen how you can opt into the Windows 7 Taskbar Jump List experience by creating a Jump List for your application (in the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/06/25/developing-for-the-windows-7-taskbar-jump-into-jump-lists-part-2.aspx"&gt;Developing for the Windows 7 Taskbar – Jump into Jump Lists – Part 2&lt;/a&gt; post.) You have also seen the Windows 7 default support for listing “Recent” or “Frequent” destinations as well as how to create your own custom categories. In this post, we will explore more of the Jump List features and discover how easy it is to add Tasks to your application's Jump List. &lt;/p&gt;  &lt;p&gt;User tasks are customized tasks that get their own Tasks category. As a developer, you can set the title of the displayed task, the icon on the left and, more important, and the “application” that is launched once you activate this task. You can view user’s tasks as shortcuts to the functionality our applications can provide. As you might remember, user tasks are the verbs in our vocabulary; for example, Windows Media Player provides a “Resume last playlist” task and Sticky Notes provides a “New note” task.&lt;/p&gt;  &lt;p&gt;A user task is usually an &lt;a href="http://msdn.microsoft.com/en-us/library/bb774950(VS.85).aspx"&gt;IShellLink&lt;/a&gt; object that launches any given application (your application or any other one you choose) with specific command line parameters. While you cannot categorize tasks, you can separate them using a special separator object. Here’s an example of a Jump List that uses a separator to split three tasks into a group of two plus an additional task:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_17EEBBC0.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_574C6F50.png" width="238" height="230" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So what does it take to add tasks to a Jump List? Well, not that much. Basically it is a single call to the &lt;b&gt;AddUserTasks&lt;/b&gt; function in an interface that we are already familiar with, the ICustomDestinationList (ICustomDestinationList::AddUserTasks(IObjectArray) Method). Looking at the code, you will see a single line of code, &lt;b&gt;hr = pcdl-&amp;gt;AddUserTasks(poa);.&lt;/b&gt;&lt;b&gt; &lt;/b&gt;However, as always, someone needs to create and build that poa, IObjectArray, and parameter and fill it with relevant information. Let’s review that process now.&lt;/p&gt;  &lt;p&gt;We are going to create a collection of IShellLinks. This collection will be later cast to the required IObjectArray parameter. The following code is the beginning of that process.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;IObjectCollection *poc;&lt;br /&gt;HRESULT hr = CoCreateInstance(&lt;br /&gt;D_EnumerableObjectCollection, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&amp;amp;poc));&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;{&lt;br /&gt;    IShellLink * psl;&lt;br /&gt;    hr = _CreateShellLink(L&lt;span style="color: #006080"&gt;&amp;quot;/Task1&amp;quot;&lt;/span&gt;, L&lt;span style="color: #006080"&gt;&amp;quot;Task 1&amp;quot;&lt;/span&gt;, &amp;amp;psl);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;    {&lt;br /&gt;        hr = poc-&amp;gt;AddObject(psl);&lt;br /&gt;        psl-&amp;gt;Release();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here you can see that we used COM (again) and CoCreate and IObjectCollection, &lt;b&gt;poc&lt;/b&gt;. Next, we call to a helper function called CreateShellLink that receives three parameters: &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The first parameter is the command line argument to the task &lt;/li&gt;

  &lt;li&gt;The second parameter is the title that will be displayed &lt;/li&gt;

  &lt;li&gt;The last parameter is a pointer to IShellLink &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The object is then filed according to the relevant information. &lt;/p&gt;

&lt;p&gt;Last, we add the recently created IShellLink to the object collection. You may ask yourself where the parameter that provides the path to the executable that we plan to launch is. Well that is a good question. For simplicity, we have hard-coded that information as shown in the following code snippet:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;{&lt;br /&gt;    hr = _CreateShellLink2(&lt;br /&gt;            L&lt;span style="color: #006080"&gt;&amp;quot;C:\\Users\\&amp;lt;my user&amp;gt;\\Documents\\new text file.txt&amp;quot;&lt;/span&gt;, &lt;br /&gt;            L&lt;span style="color: #006080"&gt;&amp;quot;NotePad&amp;quot;&lt;/span&gt;, &lt;br /&gt;            &amp;amp;psl);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;    {&lt;br /&gt;        hr = poc-&amp;gt;AddObject(psl);&lt;br /&gt;        psl-&amp;gt;Release();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here you can see we call to a hard-coded _&lt;b&gt;CreateShellLink2&lt;/b&gt; function. This receives a path to a text file as one of its parameters and, as you can see, we are launching Notepad. &lt;/p&gt;

&lt;p&gt;Here is the code for the &lt;b&gt;CreateShellLink2&lt;/b&gt; function:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;HRESULT _CreateShellLink2(&lt;br /&gt;            PCWSTR pszArguments, PCWSTR pszTitle, &lt;br /&gt;            IShellLink **ppsl)&lt;br /&gt;{&lt;br /&gt;    IShellLink *psl;&lt;br /&gt;    HRESULT hr = CoCreateInstance(&lt;br /&gt;                    CLSID_ShellLink, &lt;br /&gt;                    NULL, &lt;br /&gt;                    CLSCTX_INPROC_SERVER, &lt;br /&gt;                    IID_PPV_ARGS(&amp;amp;psl));&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;    {&lt;br /&gt;        hr = psl-&amp;gt;SetPath(c_szNotePadExecPath);&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;            {&lt;br /&gt;                hr = psl-&amp;gt;SetArguments(pszArguments);&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: #008000"&gt;// The title property is required on Jump List items &lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #008000"&gt;// provided as an IShellLink instance. This value is used &lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #008000"&gt;// as the display name in the Jump List.&lt;/span&gt;&lt;br /&gt;                    IPropertyStore *pps;&lt;br /&gt;                    hr = psl-&amp;gt;QueryInterface(IID_PPV_ARGS(&amp;amp;pps));&lt;br /&gt;                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;                    {&lt;br /&gt;                        PROPVARIANT propvar;&lt;br /&gt;                        hr = InitPropVariantFromString(pszTitle, &amp;amp;propvar);&lt;br /&gt;                        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;                        {&lt;br /&gt;                            hr = pps-&amp;gt;SetValue(PKEY_Title, propvar);&lt;br /&gt;                            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;                            {&lt;br /&gt;                                hr = pps-&amp;gt;Commit();&lt;br /&gt;                                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;                                {&lt;br /&gt;                                    hr = psl-&amp;gt;QueryInterface&lt;br /&gt;                                            (IID_PPV_ARGS(ppsl));&lt;br /&gt;                                }&lt;br /&gt;                            }&lt;br /&gt;                            PropVariantClear(&amp;amp;propvar);&lt;br /&gt;                        }&lt;br /&gt;                        pps-&amp;gt;Release();&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            hr = HRESULT_FROM_WIN32(GetLastError());&lt;br /&gt;        }&lt;br /&gt;        psl-&amp;gt;Release();&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; hr;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;To start with, again we need to use COM and CoCreate to create an IShellLink COM object. A quick look at the SDK reveals that the IShellLink object has many functions. Here are few that we will use:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;b&gt;GetPath&lt;/b&gt; Gets the path and file name of a Shell link object, that is the path to the executable &lt;/li&gt;

  &lt;li&gt;&lt;b&gt;GetShowCmd&lt;/b&gt; Gets the show command for a Shell link object, the executable name &lt;/li&gt;

  &lt;li&gt;&lt;b&gt;SetArguments&lt;/b&gt; Sets the command-line arguments for a Shell link object &lt;/li&gt;

  &lt;li&gt;&lt;b&gt;SetDescription&lt;/b&gt; Sets the description for a Shell link object; the description can be any application-defined string &lt;/li&gt;

  &lt;li&gt;&lt;b&gt;SetIconLocation&lt;/b&gt; Sets the location (path and index) of the icon for a Shell link object &lt;b&gt;SetPath&lt;/b&gt; Sets the path and file name of a Shell link object &lt;/li&gt;

  &lt;li&gt;&lt;b&gt;SetWorkingDirectory&lt;/b&gt; Sets the name of the working directory for a Shell link object &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can see, for each parameter we must get and set appropriate methods. There are additional parameters; take a look at the SDK - &lt;a href="http://msdn.microsoft.com/en-us/library/bb774950(VS.85).aspx"&gt;IShellLink&lt;/a&gt; if you want to learn more.&lt;/p&gt;

&lt;p&gt;In the above example, we set the path to Notepad (by default in the Windows 7 installation, c:\windows\notepad.exe). We also passed a hard-coded (not a good practice) command line argument pointing to a text file in my private document folder (C:\Users\&amp;lt;my user&amp;gt;\Documents\new text file.txt.) The rest of the code sets the title property that is required on Jump List items.&lt;/p&gt;

&lt;p&gt;We call the &lt;b&gt;CreateShellLink2&lt;/b&gt; and &lt;b&gt;CreateShellLink&lt;/b&gt; a few more times to add all three shortcuts as shown in the above screen capture. &lt;/p&gt;

&lt;p&gt;Now let’s add a separator.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;To add a separator to our Task List, we need to create an IShellLink, and set the PKEY_AppUserModel_IsDestListSeparator property using the COM property variant as shown in the following code snippet:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// The Tasks category of Jump Lists supports separator items. &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// These are simply IShellLink instances that have the &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//  PKEY_AppUserModel_IsDestListSeparator property set to TRUE. &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// All other values are ignored when this property is set.&lt;/span&gt;&lt;br /&gt;HRESULT _CreateSeparatorLink(IShellLink **ppsl)&lt;br /&gt;{&lt;br /&gt;    IPropertyStore *pps;&lt;br /&gt;    HRESULT hr = CoCreateInstance(&lt;br /&gt;                    CLSID_ShellLink, &lt;br /&gt;                    NULL, &lt;br /&gt;                    CLSCTX_INPROC_SERVER, &lt;br /&gt;                    IID_PPV_ARGS(&amp;amp;pps));&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;    {&lt;br /&gt;        PROPVARIANT propvar;&lt;br /&gt;        hr = InitPropVariantFromBoolean(&lt;span style="color: #0000ff"&gt;TRUE&lt;/span&gt;, &amp;amp;propvar);&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;        {&lt;br /&gt;            hr = pps-&amp;gt;SetValue(PKEY_AppUserModel_IsDestListSeparator, propvar);&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;            {&lt;br /&gt;                hr = pps-&amp;gt;Commit();&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;                {&lt;br /&gt;                    hr = pps-&amp;gt;QueryInterface(IID_PPV_ARGS(ppsl));&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            PropVariantClear(&amp;amp;propvar);&lt;br /&gt;        }&lt;br /&gt;        pps-&amp;gt;Release();&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; hr;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here you can see that we used &lt;strong&gt;CoCreate&lt;/strong&gt; to create an &lt;strong&gt;IShellLink&lt;/strong&gt; object. Next, we set a PROPVARIANT, &lt;b&gt;propvar&lt;/b&gt;, to true and set the &lt;strong&gt;IShellLink&lt;/strong&gt; object &lt;strong&gt;PKEY_AppUserModel_IsDestListSepar&lt;/strong&gt;ator property to true. This will instruct the OS to render this &lt;strong&gt;IShellLink&lt;/strong&gt; as a separator and not just as regular &lt;strong&gt;IShellLink&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;OK, that was long. Now let’s look at the short version, using .NET. For that we are going to use the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/05/18/windows-7-managed-code-apis.aspx"&gt;Windows API Code pack for the .NET Framework&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;As we can expect from .NET, we get abstraction from most of the “COM code behind” that is required. The &lt;strong&gt;Microsoft.WindowsAPICodePack.Shell.Taskbar&lt;/strong&gt; namespace includes a &lt;b&gt;JumpListLink&lt;/b&gt; object that extends the &lt;b&gt;ShellLink&lt;/b&gt; object and implements &lt;b&gt;IJumpListTasks&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;b&gt;JumpList&lt;/b&gt; class contains the &lt;b&gt;UserTasks&lt;/b&gt; collection of &lt;b&gt;IJumpListTasks&lt;/b&gt; to which you can simple add new &lt;b&gt;JumpListLink&lt;/b&gt; objects as shown in the following code snippet:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// Path to Windows system folder&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; systemFolder = &lt;br /&gt;        Environment.GetFolderPath(Environment.SpecialFolder.System);&lt;br /&gt;&lt;br /&gt;jumpList.UserTasks.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JumpListLink&lt;br /&gt;{&lt;br /&gt;    Title = &lt;span style="color: #006080"&gt;&amp;quot;Open Notepad&amp;quot;&lt;/span&gt;,&lt;br /&gt;    Path = Path.Combine(systemFolder, &lt;span style="color: #006080"&gt;&amp;quot;notepad.exe&amp;quot;&lt;/span&gt;),&lt;br /&gt;    IconReference = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; IconReference(&lt;br /&gt;(systemFolder, &lt;span style="color: #006080"&gt;&amp;quot;notepad.exe&amp;quot;&lt;/span&gt;), 0)&lt;br /&gt;});&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Using the C# 3.0 syntax, we initialize a new &lt;b&gt;JumpListLink&lt;/b&gt; object and add it to the &lt;b&gt;UserTasks&lt;/b&gt; collection. As you can see, the managed code &lt;b&gt;JumpListLink&lt;/b&gt; has very similar properties to the native one (which makes perfect sense). We also added an icon to the Notepad shortcut to the above code, but didn't provide any command line parameters. &lt;/p&gt;

&lt;p&gt;You want to add a separator? Well, that is also very easy: just add a &lt;b&gt;JumpListSeperator&lt;/b&gt; object to the UserTasks collection.&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;jumpList.UserTasks.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JumpListSeparator());&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;Please note that, as always, when working with the Windows Code pack API Taskbar, you have to call the “refresh” function in order to commit the changes, as we explained in the previous post. &lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;Taskbar.JumpList.RefreshTaskbarList();&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After the refresh, the Jump List looks as follows:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_7284C851.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_5607D671.png" width="239" height="233" /&gt;&lt;/a&gt; 

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I’ve compiled a version of a native example from the Windows 7 SDK. You can get a copy of that code from &lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers.CodeSamples/CustomJumpList.zip"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;download the Windows API Code Pack&lt;/a&gt; that includes the manage code example we used in this post. &lt;/p&gt;

&lt;p&gt;This concludes our Jump List discussion. Our next Taskbar topic is Icon Overlay.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=518119" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category></item><item><title>Developing for the Windows 7 Taskbar – Jump into Jump Lists – Part 2</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/06/25/developing-for-the-windows-7-taskbar-jump-into-jump-lists-part-2.aspx</link><pubDate>Fri, 26 Jun 2009 01:19:07 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:517510</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>13</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=517510</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/06/25/developing-for-the-windows-7-taskbar-jump-into-jump-lists-part-2.aspx#comments</comments><description>&lt;p&gt;This is the second post about the Taskbar Jump List in a series of Windows 7 Taskbar posts. In the previous post, &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/06/22/developing-for-the-windows-7-taskbar-jump-into-jump-lists-part-1.aspx"&gt;Developing for the Windows 7 Taskbar – Jump into Jump Lists – Part 1&lt;/a&gt;, we introduced the elements that comprise the Taskbar Jump Lists: the destination (also referred to as “nouns”) and the Tasks (also referred to as “verbs”). As developer, you have a large amount of control over these elements. In this post, we walk through the different APIs that you can use when programming the Taskbar Jump Lists. &lt;/p&gt;  &lt;p&gt;Before we begin, there is one very important thing you need to know. “Items” in the Recent category, or in any other category (any destination), &lt;b&gt;must have&lt;/b&gt; a &lt;b&gt;registered file handler&lt;/b&gt; &lt;b&gt;for your application&lt;/b&gt; in the registry. This &lt;b&gt;doesn’t&lt;/b&gt; mean that your application must be the &lt;b&gt;default handler&lt;/b&gt; for that specific file type, it just means that your application must have a registered handler for &lt;b&gt;all the files &lt;/b&gt;that you want to be &lt;b&gt;visible&lt;/b&gt; in the Jump List. Therefore, “items” can only be files. Remember, by clicking on one of the items in the Jump List, the OS executes the command associated with that file as it relates to your application. When you register a file handler, you also specify the application that handles this file, and you define how to pass the input parameter for the application. Another important note to remember: All the items (files) have to be local – that is, on the local hard drive, and accessible to your application. Therefore, we can say that each and every item among the Jump List destinations is an accessible, local file, with a file handler registered to your application.&lt;/p&gt;  &lt;p&gt;As we explain in the following section, once you have registered your file handlers, the OS actually helps you keep track of all your files. We will cover file handler registration in the next post. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Step 1 – Use the Out-of-the-Box Windows Experience and Default Behavior&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;By default, a Jump List contains a &lt;i&gt;Recent&lt;/i&gt; category that is populated &lt;b&gt;automatically&lt;/b&gt; for file-based applications through the &lt;b&gt;&lt;i&gt;SHAddToRecentDocs&lt;/i&gt;&lt;/b&gt; function. This function adds the used “item” (file) to the Shell's list of recently used documents. In addition to updating its list of recent documents, the Shell adds a shortcut to the user's &lt;i&gt;Recent&lt;/i&gt; directory. The Windows 7 Taskbar uses that list and the Recent directory to populate the list of recent items in the Jump Lists. &lt;/p&gt;  &lt;p&gt;Windows can also do the work for you if your application's file type is registered. Anytime you double click on a file type with a registered handler, before Windows launches your application it automatically calls &lt;b&gt;&lt;i&gt;SHAddToRecentDocs&lt;/i&gt;&lt;/b&gt; on your application's behalf. This inserts the item in the Windows Recent list and eventually into the Jump List Recent Category. The same automatic behavior occurs when using the Windows &lt;b&gt;Common File Dialog&lt;/b&gt; (CFD) to open files through our applications. Therefore, this is another good reason to use the CFD introduced in the Windows Vista timeframe, and it also plays a vital role regarding libraries, as we explained in the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/16/light-up-with-windows-7-libraries.aspx"&gt;Light Up with Windows 7 Libraries&lt;/a&gt; post. &lt;/p&gt;  &lt;p&gt;Both of the above cases exploit default Windows behavior in cases where you have a registered handler and an Application ID by which the files are associated with &lt;i&gt;Recent&lt;/i&gt; and &lt;i&gt;Frequent&lt;/i&gt; lists. In both cases, Windows automatically inserts the items into the Jump Lists unless you &lt;b&gt;specifically&lt;/b&gt; remove this functionality by using the COM API. Obviously, users also have the option to remove any items from their Jump Lists. By explicitly removing an item from the Jump List, you insert it into the Removed Items List, which we will discuss below.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Step 2 – Create Your Own Category &lt;/b&gt;&lt;/p&gt;  &lt;p&gt;If the default &lt;i&gt;Recent&lt;/i&gt; or &lt;i&gt;Frequent&lt;/i&gt; categories do not meet your application's needs, it is time to create your own &lt;i&gt;custom&lt;/i&gt; category. In order to do so, you need to use the &lt;strong&gt;ICustomDestinationList&lt;/strong&gt; interface to create a custom Destination List.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;ICustomDestinationList&lt;/strong&gt; exposes methods that allow an application to provide a custom Jump List, including destinations and tasks, for display in the Taskbar. Here are the methods that we are using for the example below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;AppendCategory &lt;/strong&gt;Defines a custom category and the destinations that it contains for inclusion in a custom Jump List &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;AppendKnownCategory &lt;/strong&gt;Specifies that the Frequent or Recent category should be included in the Jump List &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;BeginList &lt;/strong&gt;Initiates a building session for a custom Jump List &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;CommitList &lt;/strong&gt;Declares that the Jump List initiated by a call to &lt;strong&gt;BeginList&lt;/strong&gt; is complete and ready for display &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The following code snippet shows how to create a new custom list called “Custom Lists” and appends a few items to it:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; CreateJumpList()&lt;br /&gt;{    &lt;br /&gt;    ICustomDestinationList *pcdl;&lt;br /&gt;    HRESULT hr = CoCreateInstance(&lt;br /&gt;                    CLSID_DestinationList, &lt;br /&gt;                    NULL, &lt;br /&gt;                    CLSCTX_INPROC_SERVER, &lt;br /&gt;                    IID_PPV_ARGS(&amp;amp;pcdl));&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #008000"&gt;//important to setup App Id for the Jump List&lt;/span&gt;&lt;br /&gt;        hr = pcdl-&amp;gt;SetAppID(c_szAppID);&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;        {&lt;br /&gt;            UINT uMaxSlots;&lt;br /&gt;            IObjectArray *poaRemoved;&lt;br /&gt;            hr = pcdl-&amp;gt;BeginList(&lt;br /&gt;                            &amp;amp;uMaxSlots, &lt;br /&gt;                            IID_PPV_ARGS(&amp;amp;poaRemoved));&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;            {&lt;br /&gt;                hr = _AddCategoryToList(pcdl, poaRemoved);&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;                {&lt;br /&gt;                    pcdl-&amp;gt;CommitList();&lt;br /&gt;                }&lt;br /&gt;                poaRemoved-&amp;gt;Release();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here you see that we started with a standard COM initialization call. We call CoCreateInstance to initialize the &lt;b&gt;ICustomDestinationList&lt;/b&gt; object (this is the joy of working with COM….). Next, we set the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/06/18/developing-for-the-windows-7-taskbar-application-id.aspx"&gt;Application ID&lt;/a&gt; in order to allow you to start populating items to the list. &lt;/p&gt;

&lt;p&gt;The &lt;b&gt;BeginList&lt;/b&gt; function initiated the build session for the custom Jump List. This function returns the maximum number of items that can fit in a given Jump List; the default is 10. You may note the &lt;b&gt;Remove&lt;/b&gt; item parameter&lt;em&gt;, &lt;/em&gt;&lt;strong&gt;IObjectArray *poaRemoved&lt;/strong&gt;, that the &lt;strong&gt;BeginList() &lt;/strong&gt;returned as an out parameter. This holds any specific items that the user removed from the Jump List in his current session. We discuss the Removed Items List later in this post. &lt;/p&gt;

&lt;p&gt;Next we called a helper function, &lt;strong&gt;_AddCategoryToList()&lt;/strong&gt;, to do the actual work of adding items into the custom category. &lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// This is the helper function that actually appends the items to a collection &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// object HRESULT _AddCategoryToList(ICustomDestinationList *pcdl, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// IObjectArray *poaRemoved)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    IObjectCollection *poc;&lt;br /&gt;    HRESULT hr = CoCreateInstance&lt;br /&gt;                    (CLSID_EnumerableObjectCollection, &lt;br /&gt;                    NULL, &lt;br /&gt;                    CLSCTX_INPROC_SERVER, &lt;br /&gt;                    IID_PPV_ARGS(&amp;amp;poc));&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (UINT i = 0; i &amp;lt; ARRAYSIZE(c_rgpszFiles); i++)&lt;br /&gt;        {&lt;br /&gt;            IShellItem *psi;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(SHCreateItemInKnownFolder(&lt;br /&gt;                                FOLDERID_Documents, &lt;br /&gt;                                KF_FLAG_DEFAULT, &lt;br /&gt;                                c_rgpszFiles[i], &lt;br /&gt;                                IID_PPV_ARGS(&amp;amp;psi)))&lt;br /&gt;                )&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(!_IsItemInArray(psi, poaRemoved))&lt;br /&gt;                {&lt;br /&gt;                    poc-&amp;gt;AddObject(psi);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                psi-&amp;gt;Release();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        IObjectArray *poa;&lt;br /&gt;        hr = poc-&amp;gt;QueryInterface(IID_PPV_ARGS(&amp;amp;poa));&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;        {&lt;br /&gt;            pcdl-&amp;gt;AppendCategory(L&lt;span style="color: #006080"&gt;&amp;quot;Custom category&amp;quot;&lt;/span&gt;, poa);&lt;br /&gt;            poa-&amp;gt;Release();&lt;br /&gt;        }&lt;br /&gt;        poc-&amp;gt;Release();&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; hr;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Another new interface that we use is the &lt;b&gt;IObjectCollection&lt;/b&gt; that represents a collection of objects that support &lt;b&gt;IUnknown. &lt;/b&gt;To this collection we add &lt;a href="http://msdn.microsoft.com/en-us/library/bb761144.aspx"&gt;&lt;b&gt;IShellItems&lt;/b&gt;&lt;/a&gt;. Each item (file) that we added to the Jump List is of an &lt;b&gt;&lt;i&gt;IShellItem&lt;/i&gt;&lt;/b&gt; type. In the above code, we created a Shell item object for a single file that exists inside a known folder, Documents. However, before we actually added the new item to the collection, we needed to determine if the user had already removed it. If the user explicitly removed an item from the Jump List, that item will be in the &lt;i&gt;Removed Items List&lt;/i&gt; (again associated with the AppID), and, as developers, we need to respect the user's requests and avoid adding that item to the Jump List. We already have the list of removed items, &lt;b&gt;&lt;i&gt;IObjectArray *poaRemoved&lt;/i&gt;&lt;/b&gt;, that we got when we called the &lt;strong&gt;BeginList(…) &lt;/strong&gt;function when we initiated creation of a new list. &lt;/p&gt;

&lt;p&gt;At this stage, you have a collection of Shell items that the user expects to see in the Jump List. Next we added that collection to the &lt;strong&gt;ICustomDestinationList &lt;/strong&gt;object and created a new category named “&lt;i&gt;Custom category&lt;/i&gt;”, &lt;strong&gt;pcdl-&amp;gt;AppendCategory (L&amp;quot;Custom category&amp;quot;, poa);&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;So now you have successfully created a new category in the Taskbar called “Custom category” and populated it with four items. However, our work is not done yet. The final step in the CreateJumpList function is to call CommitList() to end the “transaction” that began with calling BeginList(). Only after our call to CommitList()&lt;b&gt; &lt;/b&gt;are&lt;b&gt; &lt;/b&gt;the new category and new items displayed. Calling CommitList() causes the stored list of removed items to be cleared and a new Removed Items List to begin. The ICustomDestinationList interface provides a &amp;quot;transactional base&amp;quot; API. &lt;/p&gt;

&lt;p&gt;In order to ensure a positive end user experience, make sure that a safe copy of the new repopulated list is complete and ready for use, and that the only operation the Taskbar must perform is to switch the pointer to the new list. The end result looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_3D4A7529.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_0E84BC87.png" width="451" height="367" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Using the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/05/18/windows-7-managed-code-apis.aspx" target="_blank"&gt;Windows API Code Pack&lt;/a&gt; we can write the same application using managed code.&lt;/p&gt;

&lt;p&gt;Once we are sure that we are using the same &lt;strong&gt;AppID&lt;/strong&gt; with all the Taskbar elements, we can create an instance of the Taskbar Jump List for the button that we are working on, as shown in the following code snippet. This code snippet is part of the &lt;strong&gt;CTOR&lt;/strong&gt; of the main application window:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// Set the application specific id&lt;/span&gt;&lt;br /&gt;Taskbar.AppId = appId;&lt;br /&gt;&lt;span style="color: #008000"&gt;// Retrieve the taskbar jump list&lt;/span&gt;&lt;br /&gt;jumpList = Taskbar.JumpList;&lt;br /&gt;category1 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CustomCategory(&lt;span style="color: #006080"&gt;&amp;quot;Custom Category 1&amp;quot;&lt;/span&gt;);&lt;br /&gt;category2 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CustomCategory(&lt;span style="color: #006080"&gt;&amp;quot;Custom Category 2&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;span style="color: #008000"&gt;// Add custom categories&lt;/span&gt;&lt;br /&gt;jumpList.CustomCategories.Add(category1);&lt;br /&gt;jumpList.CustomCategories.Add(category2);&lt;br /&gt;&lt;span style="color: #008000"&gt;// Default values for jump lists&lt;/span&gt;&lt;br /&gt;comboBoxKnownCategoryType.SelectedItem = &lt;span style="color: #006080"&gt;&amp;quot;Recent&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here you can see that we set the &lt;strong&gt;AppID&lt;/strong&gt; using the &lt;strong&gt;AppId&lt;/strong&gt; property and created an instance of the Taskbar Jump List using the Taskbar.&lt;strong&gt;JumpList&lt;/strong&gt; static property. We also create two categories, named Custom Category 1 and Custom Category 2. Next, we add these categories to the Jump List custom categories container. Last we set the Known category of this Taskbar Jump List to Recent. This will automatically get populated as described above. &lt;/p&gt;

&lt;p&gt;After we set up the custom category, it is time to put some content in it. To do so, we just need to call the &lt;b&gt;Add&lt;/b&gt; function to add a &lt;b&gt;JumpListItem&lt;/b&gt; to the &lt;b&gt;JumpListCollection&lt;/b&gt;. The &lt;strong&gt;JumpListItemCollection&lt;/strong&gt; is a generic collection (of&amp;lt;IJumpListItem&amp;gt;) holding &lt;b&gt;IJumpListItem &lt;/b&gt;items. &lt;strong&gt;IJumpListItem&lt;/strong&gt; item is basically some sort of wrapper for the native IShellItem. &lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// Specify path for shell item&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; path = String.Format(&lt;span style="color: #006080"&gt;&amp;quot;{0}\\test{1}.txt&amp;quot;&lt;/span&gt;,&lt;br /&gt;                            executableFolder,&lt;br /&gt;                            category1.JumpListItems.Count);&lt;br /&gt;&lt;span style="color: #008000"&gt;// Add shell item to custom category&lt;/span&gt;&lt;br /&gt;category1.JumpListItems.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JumpListItem(path));&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;First, we need to construct a path to the file we want to include in the Jump List. Please remember that we can call the Add function only if this file is local and accessible to your user. The above code (along with a few other methods that we will describe in future posts), results in a Taskbar dialog that looks like: &lt;/div&gt;

&lt;div&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_6D9149DF.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_4C9DD738.png" width="371" height="434" /&gt;&lt;/a&gt; &lt;/div&gt;

&lt;div&gt;Finally, we need to call the Taskbar.&lt;strong&gt;JumpList.RefreshTaskbarList() &lt;/strong&gt;Function. As with the native Jump List implementation, we need to “commit” the changes made to the Jump List. A closer look at this Refresh function (you have access to it in the Code Pack API) shows a call to the &lt;strong&gt;AppendCustomCategories&lt;/strong&gt; function that appends any custom categories to the Taskbar button Jump List. Within this function, you can find a managed code implementation of the native code shown above. It includes a call to the &lt;strong&gt;AppendCateogry&lt;/strong&gt; function that is a wrapper for the native &lt;strong&gt;AppendCategory&lt;/strong&gt; function above.&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;IObjectCollection categoryContent =&lt;br /&gt;    (IObjectCollection)&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CEnumerableObjectCollection();&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// Add each link's shell representation to the object array&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (IJumpListItem link &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; category.JumpListItems)&lt;br /&gt;    categoryContent.AddObject(link.GetShellRepresentation());&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// Add current category to destination list&lt;/span&gt;&lt;br /&gt;HRESULT hr = customDestinationList.AppendCategory(&lt;br /&gt;    category.Name,&lt;br /&gt;    (IObjectArray)categoryContent);&lt;br /&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;p&gt;As you can see, it is easy to opt into the Windows 7 Taskbar functionality. Windows automatically performs most of the work for you and, if you do need to create your own category, that is also very easy. &lt;/p&gt;

&lt;p&gt;In the next post we will describe how you can add new Tasks to the Jump List and how to register a file handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=517510" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category></item><item><title>Developing for the Windows 7 Taskbar – Application ID – Part 2</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/06/19/developing-for-the-windows-7-taskbar-application-id-part-2.aspx</link><pubDate>Fri, 19 Jun 2009 17:06:55 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:516770</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=516770</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/06/19/developing-for-the-windows-7-taskbar-application-id-part-2.aspx#comments</comments><description>&lt;p&gt;[June 19th - I added a code sample and new screenshots.]&lt;/p&gt;  &lt;p&gt;In response to some of the comments I included a link to the download and new screenshots to show the effect of changing Application ID in run time. And Just to make sure we are all on the same page here are two images to illustrate the power of AppID. You can clearly see that the same application (with the same original application ID) can have two different Taskbar buttons. You can also &lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers.CodeSamples/Taskbar-Application-ID.zip" target="_blank"&gt;download the code for this application&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/Taskbar_5F00_buttons_5F00_Multiplebuttone1_5F00_411DB221.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Taskbar_buttons_Multiplebuttone1" border="0" alt="Taskbar_buttons_Multiplebuttone1" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/Taskbar_5F00_buttons_5F00_Multiplebuttone1_5F00_thumb_5F00_2668EE0A.png" width="558" height="340" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/Taskbar_5F00_buttons_5F00_Multiplebuttone2_5F00_2891FEA1.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Taskbar_buttons_Multiplebuttone2" border="0" alt="Taskbar_buttons_Multiplebuttone2" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/Taskbar_5F00_buttons_5F00_Multiplebuttone2_5F00_thumb_5F00_548EAFF8.png" width="557" height="382" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Just a note as response to one of the comments. Yes you can place a different Taskbar button between to windows with different AppID!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers.CodeSamples/Taskbar-Application-ID.zip" target="_blank"&gt;download the code for this application&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can find the managed code Taskbar object in the &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;Windows API Code pack&lt;/a&gt; project.&lt;/p&gt;  &lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=516770" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Source+Code/default.aspx">Source Code</category></item><item><title>Developing for the Windows 7 Taskbar – Application ID</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/06/18/developing-for-the-windows-7-taskbar-application-id.aspx</link><pubDate>Thu, 18 Jun 2009 17:18:35 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:516746</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>35</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=516746</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/06/18/developing-for-the-windows-7-taskbar-application-id.aspx#comments</comments><description>&lt;p&gt;This is the first post in a new Windows 7 Taskbar series. One of the first Windows 7 changes that developers should pay attention to is the new Windows Taskbar. We all need to understand the functionality this feature introduces so that we can ensure that our applications work well with the Taskbar, resulting in an enhanced experience for our end users.&lt;/p&gt;  &lt;p&gt;I assume that by now you are familiar with the basic functionality that Windows 7 Taskbar offers and the reasons behind the change we made from previous taskbar versions. If you are not familiar with and haven’t seen any demonstrations of the Windows 7 Taskbar, please watch the &lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-New-Taskbar-an-overview/"&gt;Windows 7 Taskbar Overview&lt;/a&gt; webcast on Channel 9. There are also great posts on the E7 blog like &lt;a href="http://blogs.msdn.com/e7/archive/2008/11/20/happy-anniversary-windows-on-the-evolution-of-the-taskbar.aspx"&gt;The Windows 7 Taskbar&lt;/a&gt; about some of the reasons we introduced the new Taskbar and desktop experience in Windows 7. I do encourage you to read these posts and watch the video so that you have some context for the technical material we are going to cover here.&lt;/p&gt;  &lt;p&gt;The new Taskbar is probably the most noticeable change to Windows 7 when you first log on. The Windows 7 Taskbar is an application-launching and window-switching mechanism that consolidates the functions of previous Windows Desktop mechanisms, such as Quick Launch, Recent Documents, Notification Area icons, desktop shortcuts, and running application windows. Windows 7 Taskbar offers features like Jump Lists, Preview Handler, and Overlay Icons. But before we start diving into the various Windows 7 Taskbar features, let’s lay the basic foundation to our discussion and define some Windows 7 taskbar terminology. &lt;/p&gt;  &lt;p&gt;The basic component is the Taskbar button. The Taskbar button is represented as an icon displayed on the Taskbar. As you can see in the following image, the Taskbar contains several buttons. You can tell what their status is by how they are displayed.&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/Taskbar_5F00_buttons1_5F00_328301CE.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Taskbar_buttons1" border="0" alt="Taskbar_buttons1" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/Taskbar_5F00_buttons1_5F00_thumb_5F00_2A8B5F6C.png" width="564" height="137" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;For example, the Media Player button has no frame or border, but simply sits directly on the Taskbar. This indicates that Media Player is not running. But it is pinned to the Taskbar, and will stay on the Taskbar unless we unpin it. A transparent frame that lets most of the color of the underlying Taskbar through the Windows Explorer button. This indicates that the app is running but is not the active application. The Visual Studio icon has a more opaque rectangular frame underlying its icon indicating that the user is actively using this app. You will also notice that Word has a “stack” of icons representing that multiple instances of Word or multiple Windows are grouped under the same Taskbar button. It is very important to understand the logic that underlies the creation, assignment, and grouping of Taskbar buttons. &lt;/p&gt;  &lt;p&gt;A very large number of applications that run on Windows 7 (for example, Office Word 2007 and Visual Studio 2008), were not designed to work with the Windows 7 Taskbar, so how is it that they can play ball with the Taskbar, group multiple instances, and even take advantage of Word Jump Lists? Basically, a behind-the-scenes Application ID (AppID) is automatically computed and assigned to an application once you launch it. Every running application has an AppID assigned to it, either automatically computed for the app by Windows, or set by the app itself. Guess what? It is not a GUID; it is just a string (with a maximum of 128 characters), that either you provide or is being computed by the OS. All windows and applications, including Jump Lists, which have the same AppID are grouped under the same Taskbar button. Therefore, it is important to understand that every component (process, shortcut, window, Taskbar button, and document type – that is, registered file type handler) of your application has the AppID associated with it.&lt;/p&gt;  &lt;p&gt;You may ask, &amp;quot;Where do AppIDs come from?&amp;quot; As mentioned before, the OS generates Application IDs for your application using a very simple, yet important to understand heuristic. Since in Windows 7 you can assign AppIDs to individual windows, the OS tries to extrapolate the AppID from a window. Applications usually display at least one window that the OS can query for its AppID. However, most existing apps do not have an AppID attached to each window (or, for that matter, any AppID at all), and therefore the OS falls back to the process to which the window belongs for the AppID. Each process has several properties that the OS can check, like the executable of the process. But even then, the process may not provide a granular enough separation. Different shortcuts may provide different start up command line parameters to the same executable and launch different applications (imagine a “launcher” application) that will be grouped under the same Taskbar button. In such cases, the OS has the ability to look into the specific shortcut that launched the application, to find the executable, the command line parameters, and so on. Note that if you have a register file, this registration points to an application that gets launched once you double click that file. Again, this is another way to calculate the AppID. The following image illustrates this automatic computation process. &lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_709C1C7F.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_21BB5720.png" width="553" height="337" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you are interested in really understanding the internals of the Windows 7 taskbar, a great Channel 9 video describes its underlying architecture. Watch the Rob Jarrett and Ben Bets &lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Taskbar-Behind-the-Scenes/"&gt;Windows 7 Taskbar - Behind the Scenes&lt;/a&gt; video and, specifically for the Application ID overview, watch &lt;a href="http://channel9.msdn.com/posts/yochay/Jump-into-the-Windows-7-Taskbar-Jump-Lists/"&gt;Jump into the Windows 7 Taskbar Jump Lists&lt;/a&gt; (between 29:30 and 34:40).&lt;/p&gt;  &lt;p&gt;While the OS can compute AppIDs for you, you may want to have greater control over the AppID for a given application or even an individual window in your application. Assume that you have an application that hosts (runs) another application (like what happens when you debug an application using Visual Studio). Or you have several different applications or processes that you wish to group under the same Taskbar button. The Taskbar API offers you ways to control the Application ID per application or per window. IN ANY CASE, if you are writing a &lt;b&gt;new&lt;/b&gt; application that targets Windows 7, we &lt;b&gt;highly recommend&lt;/b&gt; that you provide your own application ID, as we will describe below. &lt;/p&gt;  &lt;p&gt;OK, let’s examine the API that allows you to control the AppID associations of your application.&lt;/p&gt;  &lt;p&gt;If you want to have a separate Taskbar button for each &lt;i&gt;process&lt;/i&gt; (including all windows owned by that process), you can set an explicit AppID for the entire process that affects all windows within the process that do not have their own explicit AppID. Setting the explicit process AppID is very easy. All it takes is a single call to the &lt;a href="http://msdn.microsoft.com/en-us/library/dd378422(VS.85).aspx"&gt;SetCurrentProcessExplicitAppUserModelID&lt;/a&gt; function as shown in the following code snippet:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;SetCurrentProcessExplicitAppUserModelID(c_rgszAppID[0]);&lt;/pre&gt;
Where c_rgszAppID[0] is a pointer to a string. You should note that according to the SDK documentation, &lt;em&gt;“This method must be called during an application's initial startup routine before the application presents any user interface (UI) or makes any manipulation of its Jump Lists.”&lt;/em&gt; 

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;In managed code, from the latest &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;Windows API Code Pack Library&lt;/a&gt;, you can use the &lt;b&gt;&lt;i&gt;AppID &lt;/i&gt;&lt;/b&gt;property that is part of the &lt;b&gt;&lt;i&gt;Taskbar&lt;/i&gt;&lt;/b&gt; object, which you can find in the &lt;i&gt;Microsoft.WindowsAPICodePack.Shell.Taskbar &lt;/i&gt;namespace. Using that property you can set and get the application ID of a given application. &lt;/p&gt;

&lt;p&gt;Setting the AppID for a window is a bit more complicated (but only a bit). It requires calling the &lt;a href="http://msdn.microsoft.com/en-us/library/dd378430(VS.85).aspx"&gt;SHGetPropertyStoreForWindow&lt;/a&gt; function and then manipulating the resulting &lt;a href="http://msdn.microsoft.com/en-us/library/bb761474(VS.85).aspx"&gt;IPropertyStore&lt;/a&gt; object to retrieve the requested property as shown in the following code snippet:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetAppID(HWND hWnd, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; iAppID)&lt;br /&gt;{&lt;br /&gt;    IPropertyStore *pps;&lt;br /&gt;    HRESULT hr = SHGetPropertyStoreForWindow(hWnd, IID_PPV_ARGS(&amp;amp;pps));&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;    {&lt;br /&gt;        PROPVARIANT pv;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (iAppID &amp;gt;= 0)&lt;br /&gt;        {&lt;br /&gt;            hr = InitPropVariantFromString(c_rgszAppID[iAppID], &amp;amp;pv);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            PropVariantInit(&amp;amp;pv);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;        {&lt;br /&gt;            hr = pps-&amp;gt;SetValue(PKEY_AppUserModel_ID, pv);&lt;br /&gt;            PropVariantClear(&amp;amp;pv);&lt;br /&gt;        }&lt;br /&gt;        pps-&amp;gt;Release();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here you can see how we extract the current windows property store by calling SHGetPropertyStoreForWindow, passing hWnd as refrence to the window. Next we initiate, InitPropVariantFromString(c_rgszAppID[iAppID], &amp;amp;pv), a property variant with a string that represents the AppID for that window. Finally, we set the value of the new property store to the window. &lt;/p&gt;

&lt;p&gt;Unfortunately, the current Windows API Code pack doesn’t support setting specific application IDs per window, although all you need to do is add the following function to the Taskbar.cs file:&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetWindowAppId(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; appId)&lt;br /&gt;{&lt;br /&gt;    Microsoft.WindowsAPICodePack.Shell.ShellNativeMethods.SetWindowAppId&lt;br /&gt;        (OwnerHandle, &lt;span style="color: #006080"&gt;&amp;quot;name here&amp;quot;&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Since the Windows API Code Pack provides the source code, you can actually check the specific implementation of SetWindowAppId function and see for yourself that it is very similar to the SetAppID example above. Note you don’t have to use the full qualified assembly name “&lt;em&gt;Microsoft.WindowsAPICodePack.Shell’&lt;/em&gt;, but I did to help you navigate the Windows API Code Pack hierarchy.&lt;/p&gt;

&lt;p&gt;By the way, the window AppID is dynamic, so it’s entirely possible for a window to show up as part of one Taskbar button and then change its AppID so that it appears on an entirely different Taskbar button. This has interesting effects. For example, the Jump List is attached to a Taskbar button (with a specific AppID), so the same window might show a different Jump List when it is reattached to an entirely different Taskbar button. This potentially can confuse users, so the recommended practice is to set the window AppID and stick to it, using the same process for determining the AppID every time the window displays. &lt;/p&gt;

&lt;p&gt;You can find the managed code Taskbar object in the &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;Windows API Code pack&lt;/a&gt; project.&lt;/p&gt;

&lt;p&gt;[&lt;a href="http://blogs.microsoft.co.il/blogs/sasha"&gt;Sasha Goldshtein&lt;/a&gt; helped write this post, and you can find his original posting &lt;a href="http://blogs.microsoft.co.il/blogs/sasha/archive/2009/02/15/windows-7-taskbar-application-id.aspx"&gt;here&lt;/a&gt;].&lt;/p&gt;

&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=516746" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Source+Code/default.aspx">Source Code</category></item><item><title>Windows 7 RC Training Kit for Developers</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/06/12/windows-7-rc-training-kit-for-developers.aspx</link><pubDate>Fri, 12 Jun 2009 17:09:38 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:516507</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=516507</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/06/12/windows-7-rc-training-kit-for-developers.aspx#comments</comments><description>&lt;p&gt;This week we released the &lt;u&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=12100526-ed26-476b-8e20-69662b8546c1&amp;amp;displaylang=en" target="_blank"&gt;Windows 7 RC Training Kit for Developers&lt;/a&gt;&lt;/u&gt; as part of our ongoing effort to give you, all the Windows developers out there, and valuable content to work with while making your application shine on Windows 7. This version of the training kit includes 10 presentations and 8 Hands-On-Labs (HOL), covering most of the Windows 7 light-up features as well as application compatibility topics. Note that the HOL gives you the opportunity to get firsthand experience in programming key Windows 7 Light-Up features, such as the Taskbar, Libraries, Multi-Touch, Sensors and Location, Graphics, Ribbon, Trigger Start Services, Instrumentation and Event Tracing for Windows (ETW). We also provide a brief Application Compatibility overview. &lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="551"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="274"&gt;This is an “early preview” to the full set of Windows 7 Training for Developers that will be released shortly after RTM. You can &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=12100526-ed26-476b-8e20-69662b8546c1&amp;amp;displaylang=en" target="_blank"&gt;download&lt;/a&gt; the training kit and get started, but make sure you have a Windows 7 RC machine to work with, and install Visual Studio 2008 SP 1 and Windows 7 RC SDK as some of the native applications requires libraries from the SDK.&lt;/td&gt;        &lt;td valign="top" width="275"&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_62F158D2.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_1A576A01.png" width="240" height="209" /&gt;&lt;/a&gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h3&gt;Modules:&lt;/h3&gt;  &lt;h5&gt;Taskbar&lt;/h5&gt;  &lt;p&gt;The Windows 7 Taskbar is a differentiating opportunity that allows applications to shine on the Windows 7 platform. The new Taskbar streamlines many end-user scenarios including launching applications, switching between running applications and windows within a single application, managing recent/frequent user destinations, accessing common application tasks, reporting progress and status notifications through the taskbar button, and controlling the application without leaving the taskbar thumbnail. The Taskbar is the end user’s primary point-of-contact for initiating and managing activities; as such, the integration of the new taskbar features into modern Windows 7 applications is a critically important goal. This module talks about the different aspects and APIs associated with programming the Windows 7 Taskbar. &lt;/p&gt;  &lt;h5&gt;Libraries&lt;/h5&gt;  &lt;p&gt;Libraries are the new entry points to user data. Libraries are a natural evolution of the 'My Documents' folder concept that blends into the Windows Explorer user experience. A library is a common store of user defined locations that applications can leverage to manage user content as their part of the user experience. Because libraries are not file system locations, you will need to update some applications to work with them like folders. This module explains the basic concepts underlying Windows 7 Libraries, including how to make your application library-aware, how to work with libraries as though they were file system folders, and how to leverage the library system.&lt;/p&gt;  &lt;h5&gt;Multi-Touch &lt;/h5&gt;  &lt;p&gt;Windows 7 features improved touch and gesture support that empowers developers to quickly and easily create unique application experiences that go beyond simple mouse pointing, clicking, and dragging. The new multi-touch APIs support rich gestures, such as pan, zoom, and rotate. The Windows 7 Multi-Touch Platform also provides raw touch data inputs and advance manipulation and interties. This module explains the basics of Windows 7 multi-touch and its APIs.&lt;/p&gt;  &lt;h5&gt;Sensor and Location Platform&lt;/h5&gt;  &lt;p&gt;Windows 7 has changed how developers use sensors. The Sensor and Location Platform includes native support for sensors, expanded by a new development platform for working with sensors, including location sensors such as GPS devices. Built on the Sensor platform, the new Windows Location APIs enable application developers to access the user’s physical location information. This module explains what the Sensor and Location Platform is and how to work with its APIs.&lt;/p&gt;  &lt;h5&gt;Ribbon&lt;/h5&gt;  &lt;p&gt;Windows 7 incorporates the Ribbon interface introduced in Office 2007 throughout the operating system, enabling improved user interface development on the platform. This means that developers can eliminate much of the drudgery of Win32 UI development and deliver a rich, graphical, animated, and highly familiar user interfaces by using a markup-based UI and a small, high-performance, native code runtime. The Ribbon control helps developers improve usability by exposing your application's most frequently accessed features directly to end users. The Ribbon makes it easier for end users to find and use application features because functionality is more visible, resulting in greater productivity. This module shows the different aspects of the Windows 7 Ribbon and provides a guide on how to incorporate the Windows 7 Ribbon into existing applications. &lt;/p&gt;  &lt;h5&gt;Background Processes, Services, and Tasks&lt;/h5&gt;  &lt;p&gt;Services and background processes have tremendous influence on the overall performance of the system, and therefore the applications. If we could cut down on the total number of services, we could reduce the total power consumption and increase the overall stability of the system. The Windows 7 Service Control Manager has been extended so that a service can be automatically started and stopped when a specific system event, or trigger, occurs on the system. Trigger-start capabilities remove the need for services to start up automatically at computer startup and then poll or wait for an event to occur. This module explains the different options available to developers for configuring and using trigger-start services. &lt;/p&gt;  &lt;h5&gt;Windows 7 Instrumentation and Performance&lt;/h5&gt;  &lt;p&gt;Windows 7 includes new Event Tracing for Windows (ETW) capabilities that developers can take advantage of during the development process to optimize application performance. Instrumentation has always been part of Windows, but Windows 7 includes new ETW underlying technology that makes the task of including instrumentation in your application a whole lot easier. This module describes the different options for using instrumentation in Windows, including the new ETW.&lt;/p&gt;  &lt;h5&gt;Windows 7 Application Compatibility&lt;/h5&gt;  &lt;p&gt;Windows 7 is built on top of Windows Vista, which means if your application does not work or if it has some issues when running on Windows Vista, most probably it will have similar issues running on Windows 7. This module is a short overview of the top major issues regarding Windows 7 compatibility, including Data Redirection, Service Isolation, Version Checking, and High DPI.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=516507" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Multi-Touch/default.aspx">Multi-Touch</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sensor+and+Location/default.aspx">Sensor and Location</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Libraries/default.aspx">Libraries</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7+Instrumentation+and+Performance/default.aspx">Windows 7 Instrumentation and Performance</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7+Application+Compatibility/default.aspx">Windows 7 Application Compatibility</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/ETW/default.aspx">ETW</category></item><item><title>Windows 7 Libraries – Managed Code</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/06/09/windows-7-libraries-managed-code.aspx</link><pubDate>Tue, 09 Jun 2009 21:53:49 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:516360</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=516360</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/06/09/windows-7-libraries-managed-code.aspx#comments</comments><description>&lt;p&gt;We are wrapping up our comprehensive drilldown into the Windows 7 Libraries API and architecture with one final post about the managed API for working with Windows 7 Libraries. Previously we talked about: &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/06/understanding-windows-7-libraries.aspx"&gt;Understanding Windows 7 Libraries&lt;/a&gt;, &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/14/libraries-under-the-hood.aspx"&gt;Libraries Under the Hood&lt;/a&gt;, &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/16/light-up-with-windows-7-libraries.aspx"&gt;Light Up with Windows 7 Libraries&lt;/a&gt;, &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/23/consuming-the-contents-of-windows-7-libraries.aspx"&gt;Consuming the Contents of Windows 7 Libraries&lt;/a&gt;, &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/05/14/stay-in-sync-with-windows-7-libraries.aspx"&gt;Stay in Sync with Windows 7 Libraries&lt;/a&gt;, &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/05/08/windows-7-libraries-ishellfolder.aspx"&gt;Windows 7 Libraries Helpers&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this post we focus on the managed API for working with Windows 7 Libraries. The Windows API Code Pack for the Microsoft .NET Framework Library (Windows API Code Pack) provides a .NET interface into the Windows native API, thereby enabling the 7 key Windows Light-Up features as well as tapping into more advanced shell integration, as we described in the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/05/18/windows-7-managed-code-apis.aspx"&gt;Windows 7 Managed Code APIs post&lt;/a&gt;. You can &lt;a href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;download the Windows Code Pack API&lt;/a&gt;&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="0" width="570"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="297"&gt;The Windows API Code Pack has a very good managed interface to the Windows Shell, and particularly to the Windows 7 Libraries API. &lt;b&gt;&lt;i&gt;ShellLibrary&lt;/i&gt;&lt;/b&gt; (a part of the &lt;b&gt;&lt;i&gt;Microsoft.WindowsAPICodePack.Shell&lt;/i&gt;&lt;/b&gt; dll that you need to add as a reference to your .NET application in order to work with Windows 7 libraries), is the only object that represents Libraries. The image to the left displays the &lt;b&gt;&lt;i&gt;ShellLibrary&lt;/i&gt;&lt;/b&gt; class.           &lt;br /&gt;          &lt;br /&gt;Now you can start working with Libraries. First, you need to create a Library object using one of the four available constructors. You might want to use the constructor that takes a Known Folder as a parameter. This is to allow developers easy maintenance while developing. Note, however, that most constructors receive an &lt;b&gt;&lt;i&gt;overwrite&lt;/i&gt;&lt;/b&gt; Boolean. Make sure you don’t overwrite your own existing Documents library (or any other library), since the creation of a new&lt;/td&gt;        &lt;td valign="top" width="271"&gt;         &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_39B6CB44.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_3F916EDD.png" width="254" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;div id="codeSnippetWrapper"&gt;ShellLibrary object saves the library’s XML detention file to the Library’s Known Folder, as we described in &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/14/libraries-under-the-hood.aspx"&gt;Libraries Under the Hood&lt;/a&gt;. The following single line of code creates a new ShellLibrary object, thus creating a new Library.&lt;/div&gt;  &lt;div&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;ShellLibrary library = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ShellLibrary(“&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; test lib1”, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;If you don’t have to create a new library, you can load an existing library to obtain the required ShellLibrary object. Keep in mind that all load functions are static functions that don’t require an already existing ShellLibrary instance. Every load function’s last parameter is a &lt;b&gt;&lt;i&gt;isReadOnly&lt;/i&gt;&lt;/b&gt; Boolean that you may use when you just need to read a library's contents and without changing it. For example, an application that backs up all your libraries has no need to change the library. The following code snippet is all that is needed to load an existing library:&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;ShellLibrary library = ShellLibrary.Load(&lt;span style="color: #006080"&gt;&amp;quot;My Pictures&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;OK, you have a ShellLibrary object -- what can you do with it? Well there are few things ways to have fun with libraries. First, you can add or remove specific folders from the library. Remember that libraries are just abstract containers and don’t really hold files, but just point to the actually folders that do hold the files, as explained in the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/06/understanding-windows-7-libraries.aspx"&gt;Understanding Windows 7 Libraries&lt;/a&gt; post. To add a folder just call the &lt;b&gt;&lt;i&gt;Add&lt;/i&gt;&lt;/b&gt; function, in a similar way, call the &lt;b&gt;&lt;i&gt;remove&lt;/i&gt;&lt;/b&gt; function to remove a folder. You can add or remove folders by either using a specific path represented by a string or using a &lt;b&gt;&lt;i&gt;FileSystemFolder&lt;/i&gt;&lt;/b&gt; object as shown in the following code snippet:&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Add(FileSystemFolder item);&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Add(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; folderPath);&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; Remove(FileSystemFolder item);&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; Remove(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; folderPath);&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;Besides managing folders in your library, you can also set the default save location of the library by using the &lt;b&gt;&lt;i&gt;DefaultSaveFolder&lt;/i&gt;&lt;/b&gt; property. Assuming the &lt;b&gt;&lt;i&gt;library&lt;/i&gt;&lt;/b&gt; is a ShellLibrary object, the following code snippet returns the default save location of the Library:&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;String dsfStr = library.DefaultSaveFolder&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Note that when setting the default save folder, you need to provide a valid system folder for which you have write and read permission. If this folder is not already part of the library, it will be added to the library and will become the default save location. As a developer, you can also add unsupported folder locations that are not indexed and can’t be indexed. &lt;/p&gt;

&lt;p&gt;Another very cool feature is control of the library icon. This one of those features that end users don’t have access to, and it is SO easy to use, as shown in the following code snippet:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;library.IconResourceId = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; IconReference(icon);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You will have to obtain an &lt;b&gt;&lt;i&gt;IconReference&lt;/i&gt;&lt;/b&gt; object, but after doing so you get to change the library’s Icon and set your own special icons. This is a really fun feature to play with, as you can see from the following picture: &lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;&amp;#160;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_64293C6A.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_509BDCC9.png" width="550" height="374" /&gt;&lt;/a&gt; 

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Another important feature of the &lt;b&gt;&lt;i&gt;ShellLibrary&lt;/i&gt;&lt;/b&gt; object is the capability to list all the items and folders in a library. The ShellLibrary object implements the &lt;strong&gt;&lt;em&gt;IList&amp;lt;FileSystemFolder&amp;gt;&lt;/em&gt;&lt;/strong&gt; interface. This supports enumeration of the folders in the library by calling the &lt;b&gt;&lt;i&gt;GetEnumerator&lt;/i&gt;&lt;/b&gt; function or by using the &lt;b&gt;&lt;i&gt;foreach&lt;/i&gt;&lt;/b&gt; statement as shown in the following code snippet that prints the folder’s name and default save location:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (ShellFolder folder &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; library)&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine(&lt;br /&gt;            &lt;span style="color: #006080"&gt;&amp;quot;\t\t{0} {1}&amp;quot;&lt;/span&gt;, &lt;br /&gt;            folder.Name, &lt;br /&gt;            defaultSaveFolder == folder.Name ? &lt;span style="color: #006080"&gt;&amp;quot;*&amp;quot;&lt;/span&gt; : &lt;span style="color: #006080"&gt;&amp;quot;&amp;quot;&lt;/span&gt;)&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You can control the library type by using the &lt;b&gt;LibraryType&lt;/b&gt; property, and you can elect to pin the library listing to the left navigation pane of Windows Explorer using the &lt;b&gt;&lt;i&gt;IsPinnedToNavigationPane&lt;/i&gt;&lt;/b&gt; property. &lt;/p&gt;

&lt;p&gt;Last, I want to talk about displaying the Library Manager window. It is important to display this window if you wish to create a consistent user experience for managing libraries in Windows Explorer and your application. Since displaying the Library Manager window displays a new dialog window in an existing application, you need to take into account the technology used by the application. The function &lt;b&gt;&lt;i&gt;ShowManageLibraryUI&lt;/i&gt;&lt;/b&gt; can receive either a Win32 window handle (whnd) that will work great with WinForms, or a WPF windows object for WPF applications.&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;library.ShowManageLibraryUI(IntPtr.Zero, “title of dialog”, &lt;span style="color: #006080"&gt;&amp;quot;help text…&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;The last thing we are going to talk about is deleting a library. The ShellLibrary object doesn’t have a self destruct mechanism and therefore you can’t delete a library using the &lt;b&gt;&lt;i&gt;ShellLibrary&lt;/i&gt;&lt;/b&gt; object. To delete a library you need to delete the library XML definition file. The code snippet below gets a string representing the library name that correlates to same library definition file. See &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/06/understanding-windows-7-libraries.aspx"&gt;Understanding Windows 7 Libraries&lt;/a&gt; for more information. &lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; DeleteLibrary(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; name)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; librariesPath = Path.Combine(&lt;br /&gt;        Environment.GetFolderPath(&lt;br /&gt;            Environment.SpecialFolder.ApplicationData),&lt;br /&gt;            ShellLibrary.LibrariesKnownFolder.RelativePath);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; libraryPath = Path.Combine(librariesPath, name);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; libraryFullPath = Path.ChangeExtension(libraryPath, &lt;span style="color: #006080"&gt;&amp;quot;library-ms&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    File.Delete(libraryFullPath);&lt;br /&gt;}&lt;/pre&gt;
As you can see, we first use a combination of the &lt;b&gt;&lt;i&gt;Environment.SpecialFolder.ApplicationData&lt;/i&gt;&lt;/b&gt; and the ShellLibrary &lt;b&gt;&lt;i&gt;ShellLibrary.LibrariesKnownFolder.RelativePath&lt;/i&gt;&lt;/b&gt; to assemble the folder in which all the libraries definition files are stored. Then we append the library-ms file extension, and finally we delete the file. Remember, by deleting the file, we delete the library; so again, be careful not to delete any important libraries. &lt;/div&gt;

&lt;p&gt;We have covered all the important functionality of the Libraries managed code API and, together with the previous posts; you now should have a very good sense of how Windows 7 Libraries work and how to use them in your applications. &lt;/p&gt;

&lt;p&gt;In addition, you can get first-hand coding experience with Windows 7 by going through the Windows 7 Libraries Hands-On-Lab (HOL) that is part of the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=12100526-ed26-476b-8e20-69662b8546c1&amp;amp;displaylang=en"&gt;Windows 7 RC Training Kit for Developers&lt;/a&gt;. The Library HOL includes the code used in this post, so go ahead and download the training kit. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=516360" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Libraries/default.aspx">Libraries</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category></item><item><title>New Windows 7 Videos on Channel 9</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/05/07/new-windows-7-videos-on-channel-9.aspx</link><pubDate>Thu, 07 May 2009 19:58:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:514042</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>22</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=514042</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/05/07/new-windows-7-videos-on-channel-9.aspx#comments</comments><description>&lt;p&gt;Note &amp;ndash; this post will be updated from time to time, to include new content. Last update:&amp;nbsp;&lt;strong&gt;June 13&lt;/strong&gt;&lt;sup&gt;&lt;strong&gt;th&lt;/strong&gt; &lt;/sup&gt;(New Sensor, Location and Windows Animation videos)&lt;/p&gt;
&lt;p&gt;During the past couple of months, we have being working on Windows 7 videos featuring the new technologies in Windows 7. We&amp;rsquo;ve also created a &lt;a href="http://channel9.msdn.com/windows"&gt;Windows Topic area on Channel 9&lt;/a&gt; to make it easier for you to find specific Windows 7 content. This topic area includes all the Windows 7 videos since PDC08, which was when we first introduced Windows 7. Since PDC, we have created enough content about specific Windows 7 features that it makes sense to group these topics into categories so they are easier for potential viewers to find. We hope these videos will help you to get started programming for Windows 7. Here is one new of the many videos we have for you on Channel 9.&lt;/p&gt;
&lt;p&gt;
&lt;object type="application/x-silverlight-2" height="275" width="367" data="data:application/x-oleobject;base64,QfXq3+HzJEysrJnDBxUISgAIAADuJQAAbBwAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;Here is the list of category topics and their associated videos:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Kernel and Internals&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/shows/Going+Deep/Dave-Probert-Inside-Windows-7-User-Mode-Scheduler-UMS/"&gt;Inside Windows 7 - User Mode Scheduler&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/shows/Going+Deep/Chittur-Subbaraman-Inside-Windows-7-Service-Controller-and-Background-Processing/"&gt;Inside Windows 7 - Service Control Manager&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/shows/Going+Deep/Mark-Russinovich-Inside-Windows-7/"&gt;Mark Russinovich &amp;ndash; Inside Windows 7&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/philpenn/New-NUMA-Support-with-Windows-7-and-Windows-Server-2008-R2-PM-Talk/"&gt;New NUMA Support with Windows 7&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/pdc2008/PC51/"&gt;Windows 7: Best Practices for Developing for Windows Standard User&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Taskbar&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-New-Taskbar-An-Overview/"&gt;Windows 7 New Taskbar - An Overview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Taskbar-Behind-the-Scenes/"&gt;Taskbar - Behind the Scenes&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Designing-the-Windows-7-Taskbar/"&gt;Designing the Windows 7 Taskbar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Jump-into-the-Windows-7-Taskbar-Jump-Lists/"&gt;Jump into the Windows 7 Taskbar Jump Lists&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Taskbar-Beta-Feedback/"&gt;Windows 7 Taskbar Beta Feedback&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Taskbar-Advance-Topics/"&gt;Windows 7 Taskbar Advanced Topics&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Graphics&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Graphics-Architecture-Overview-Part-1/"&gt;Windows 7 Graphics Architecture Overview &amp;ndash; Part 1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Graphics-Architecture-Overview-Part-2/"&gt;Windows 7 Graphics Architecture Overview &amp;ndash; Part 2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Graphics-Architecture-Overview-Part-3/"&gt;Windows 7 Graphics Architecture Overview &amp;ndash; Part 3&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowsteamblog.com/posts/yochay/Windows-7-Graphics-WIC/" id="ctl00_MainPlaceHolder_Starter_TitleLink"&gt;Windows 7 Graphics - WIC&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=" http://channel9.msdn.com/posts/yochay/Windows-7-Graphics--High-DPI/"&gt;Windows 7 Graphics - High DPI&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Multi-Touch&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/benriga/Using-Touch-in-Line-of-Business-Apps/"&gt;Using Touch in Line-of-Business Applications&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Programming-Windows-7-Multi-Touch--Part-1/"&gt;Programming Windows 7 Multi Touch &amp;ndash; Part 1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Programming-Windows-7-Multi-Touch-Part-2/"&gt;Programming Windows 7 Multi Touch - Part 2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Sensor and Location&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/pdc2008/PC25/"&gt;Windows 7: The Sensor and Location Platform - Building Context Aware Applications&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Sensor-and-Location-Platform-Overview/"&gt;Windows 7 Sensor and Location Platform Overview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Location-Platform-Overview/"&gt;Windows 7 Location Platform Overview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Sensor-and-Location-Platform--Deep-Dive/" id="ctl00_MainPlaceHolder_Starter_TitleLink"&gt;Windows 7 Sensor and Location Platform &amp;ndash; Deep Dive&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ribbon&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/A-lap-around-Windows-7-new-Scenic-Ribbon/"&gt;A Lap around Windows 7 Ribbon&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Ribbon-Markup-Overview/"&gt;Ribbon Markup Overview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Ribbon-Deep-Dive/"&gt;Ribbon Deep Dive&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Windows Animation Manager&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-Scenic-Animation-Overview/"&gt;Windows Animation Overview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Inside-Windows-7-Animation-Manager-Deep-Dive/"&gt;Inside Windows 7: Animation Manager Deep Dive and Tutorial&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Libraries and Federated Search&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/Dan/Windows-7-Find-and-Organize-Part-1-The-User-Experience/"&gt;Windows 7: Find and Organize Part 1 - The User Experience&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/Dan/Windows-7-Find-and-Organize-Part-2-Building-Federated-Search-applications/"&gt;Windows 7: Find and Organize Part 2 - Building Federated Search applications&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/pdc2008/PC16/"&gt;Windows 7: Empower users to find, visualize and organize their data with Libraries and the Explorer&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;PowerShell&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/philpenn/PowerShell-V2-Functions/"&gt;PowerShell V2 Functions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/philpenn/PowerShell-V2-Sessions-and-Debugging/"&gt;PowerShell V2 Sessions and Debugging&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/philpenn/PowerShell-V2-Modules/"&gt;PowerShell V2 Modules&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;General &lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/ContinuumNews/The-story-behind-a-few-of-the-new-Windows-7-wallpapers/"&gt;The story behind a few of the new Windows 7 wallpapers&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/ContinuumNews/Windows-7-RC-Features-Slideshow-on-eWeek/"&gt;Windows 7 RC Features Slideshow on eWeek&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=514042" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Multi-Touch/default.aspx">Multi-Touch</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sensor+and+Location/default.aspx">Sensor and Location</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Libraries/default.aspx">Libraries</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Channel+9/default.aspx">Channel 9</category></item><item><title>Consuming the Contents of Windows 7 Libraries</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/04/23/consuming-the-contents-of-windows-7-libraries.aspx</link><pubDate>Thu, 23 Apr 2009 23:16:28 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:512134</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>22</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=512134</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/04/23/consuming-the-contents-of-windows-7-libraries.aspx#comments</comments><description>&lt;p&gt;This is the fifth post about Windows 7 Libraries. By now, you should be familiar with Windows 7 Libraries (&lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/06/understanding-windows-7-libraries.aspx"&gt;Understanding Windows 7 Libraries&lt;/a&gt;) and understand the internal structure of Libraries and how they integrate into the Windows Shell (&lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/14/libraries-under-the-hood.aspx"&gt;Libraries Under the Hood&lt;/a&gt;). In the previous post, we explained the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/16/light-up-with-windows-7-libraries.aspx"&gt;different programming models and ways to work with Windows 7 Libraries&lt;/a&gt;. In this post, we focus on the Windows Shell Programming model that you can use to access libraries even without using the latest IShellLibrray APIs.&lt;/p&gt;  &lt;p&gt;In the previous post, we talked about the importance of using the right version of the Common File Dialog (CFD) to enable the complete Libraries user experience in Windows 7. In this post we will further explorer the opportunities to let users select and consume Libraries as if they where regular folders. Let’s imagine the case of a slideshow application that presents users' pictures. By using the Pictures Library, users are essentially telling the system that their important pictures are stored in the Pictures Library, and therefore, our slideshow application can simply be pointed directly to the Pictures Library and show the users' entire pictures collections. Furthermore, from developers’ point of view, using the Libraries system can eliminate the need to maintain a separate configuration file or database, since developers can rely on the Libraries System. But before we dive into the Shell Libraries programming APIs, we need to understand the few concepts regarding the Shell Programming Model. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Shell Programming Model&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;IShellItem&lt;/b&gt;, commonly referred to as an item, is the currency of the Shell UI model and its programming model. Items are individual, self-contained content sources. Take for example the above-mentioned Common File Dialogs. Quite few of the interface methods used for controlling the file dialogs use Shell items to refer to folders instead of file system paths. This is important because the CFD can communicate information about both file system folders and other virtual folders that you find in the shell, such as the Control Panel or the Computer folder. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;IShellFolder&lt;/b&gt; interface represents shell folder objects from the shell namespace. Using IShellFolder you can traverse through the contents of a folder, to retrieve the display name of an item in a folder, parse a display name relative to the folder, and obtain an item ID list. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;IShellLink&lt;/b&gt; interface represents a link, usually to a file, folder, or an executable. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;IPropertyStore&lt;/b&gt; interface can be used to manage the property store associated with various shell objects. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;IShellLibrary&lt;/b&gt; interface represents a Windows 7 Library, which we will cover in depth in future posts. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Now that we have defined the different players in the Shell Programming Model, we can see how Libraries fit into this model. Since Libraries are not file system locations, you cannot use file system-specific APIs. Therefore, you have two main options to consume library contents - the Shell Programming Model and the new IShellLibrary API.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Using the Shell Programming Model&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can use the &lt;i&gt;IShellItem&lt;/i&gt; and &lt;i&gt;IShellFolder&lt;/i&gt; interfaces and a bunch of helper functions to enumerate the contents of Libraries just as if they were regular folders. This means that applications can consume Libraries contents without using the new Libraries API and with very little change to their existing code. &lt;/p&gt;  &lt;p&gt;The following code snippet shows how to use the &lt;i&gt;IShellFolder&lt;/i&gt; interface to enumerate through the entire contents of the Picture library.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;IShellItem *psi;&lt;br /&gt;HRESULT hr =  SHGetKnownFolderItem(&lt;br /&gt;            FOLDERID_PicturesLibrary, &lt;br /&gt;            KF_FLAG_CREATE, &lt;br /&gt;            NULL, &lt;br /&gt;            IID_PPV_ARGS(&amp;amp;psi));&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(SUCCEEDED(hr))&lt;br /&gt;{&lt;br /&gt;    IShellFolder *psf;&lt;br /&gt;    hr = psi-&amp;gt;BindToHandler(NULL, BHID_SFObject, IID_PPV_ARGS(&amp;amp;psf));&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(SUCCEEDED(hr))&lt;br /&gt;    {&lt;br /&gt;        IEnumIDList *penumIDList;&lt;br /&gt;        psf-&amp;gt;EnumObjects(NULL, &lt;br /&gt;                        SHCONTF_FOLDERS  | SHCONTF_NONFOLDERS, &lt;br /&gt;                        IID_PPV_ARGS(&amp;amp;penumIDList));&lt;br /&gt;        &lt;span style="color: #008000"&gt;//use penumIDList to enumerate the content of the folder&lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here you can see that by using the helper function &lt;i&gt;SHGetKnownFolderItem,&lt;/i&gt; we can retrieve the correct library location by passing the &lt;i&gt;FOLDERID_PicturesLibrary,&lt;/i&gt; which is a GUID representing the known folder, in our case the Pictures Library.The &lt;i&gt;SHGetKnownFolderItem&lt;/i&gt; is a Shell Helper function and is part of a larger group of helper functions that can be found in the &lt;i&gt;shlobj.h&lt;/i&gt; header file in the Windows 7 SDK. A successful call will fill the &lt;i&gt;IShellItem *psi&lt;/i&gt; with the correct information about the Library represented as a Shell Item. From this point the rest of the code is standard Windows Shell programming, where we use the &lt;i&gt;BindToHandler&lt;/i&gt; to bind the previously obtained Shell Item to a Shell folder. Next, we enumerate through the different items in the Shell folder, which in case of a library can be either files or folders. Note the SHCONTF_FOLDERS | SHCONTF_NONFOLDERS flags that we are passing, this is telling the shell folder that we want to return all of the files and folders in a library. We could pass SHCONTF_NAVIGATION_ENUM to get the library locations instead of the library &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the New IShellLibrary API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can achieve the same functionality as the code above by using the new Windows 7 IShellLibrary API as shown by the next code snippet. &lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;IShellLibrary *pslLibrary;&lt;br /&gt;HRESULT hr = SHLoadLibraryFromKnownFolder(&lt;br /&gt;                FOLDERID_PicturesLibrary, &lt;br /&gt;                STGM_READ, &lt;br /&gt;                IID_PPV_ARGS(&amp;amp;pslLibrary));&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(SUCCEEDED(hr))&lt;br /&gt;{&lt;br /&gt;    IShellItemArray *psiaFolders;&lt;br /&gt;    hr = pslLibrary-&amp;gt;GetFolders(&lt;br /&gt;                            LFF_STORAGEITEMS, &lt;br /&gt;                            IID_PPV_ARGS(&amp;amp;psiaFolders)); &lt;br /&gt;    IEnumShellItems *penumShellItems;&lt;br /&gt;    psiaFolders-&amp;gt;EnumItems(&amp;amp;penumShellItems);&lt;br /&gt;    &lt;span style="color: #008000"&gt;//work with penumShellItem to enumerate the library locations.&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here you can see that we used another helper function &lt;i&gt;SHLoadLibraryFromKnownFolder&lt;/i&gt; to create the &lt;i&gt;IShellLibrary&lt;/i&gt; object from which we can call the &lt;i&gt;GetFolders&lt;/i&gt; method to return an &lt;i&gt;IShellItemArray&lt;/i&gt; that contains the library locations. This is the same as using SHCONTF_NAVIGATION_ENUM in the above Shell programming model example. You can directly enumerate the contents of each of the library locations using the shell programming model or get the path of each of the locations.&lt;/p&gt;

&lt;p&gt;In the next post we will focus more on the rest of the IShellLibrary API.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=512134" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Libraries/default.aspx">Libraries</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category></item><item><title>Light Up with Windows 7 Libraries</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/04/16/light-up-with-windows-7-libraries.aspx</link><pubDate>Thu, 16 Apr 2009 22:55:46 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:511856</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>39</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=511856</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/04/16/light-up-with-windows-7-libraries.aspx#comments</comments><description>&lt;p&gt;OK, it is time we to dive into the gist of Windows 7 Libraries. This is the fourth post in a series of Windows 7 Libraries posts. So far, we discussed what Windows 7 Libraries are (&lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/06/understanding-windows-7-libraries.aspx"&gt;Understanding Windows 7 Libraries&lt;/a&gt;) and we reviewed the internal structure of Libraries and how they integrate into the Windows Shell &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/14/libraries-under-the-hood.aspx"&gt;Libraries Under The Hood&lt;/a&gt;. In this post, we review the different programming models developers can use when integrating Libraries into their applications.&lt;/p&gt;  &lt;p&gt;Libraries are the new entry points for user’s data In Windows 7. Libraries are an integral part of the Shell and are promoted across Windows in Windows Explorer, Start Menu, and Common File Dialog. Windows 7 Users will &lt;b&gt;use Libraries&lt;/b&gt; in their day-to-day activities. As such, they will &lt;b&gt;expect&lt;/b&gt; applications that are running on Windows 7 to work properly with their Libraries and provide the same user experience as Windows Explorer. It is therefore important that, as developers, we know how to work with libraries and make our applications Libraries-aware.&lt;/p&gt;  &lt;p&gt;But before we start, I want to note that while most applications should just work fine with Windows 7 Libraries, there is an opportunity to tap into the Windows 7 Libraries environment to provide a richer user experiences. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;b&gt;&lt;u&gt;Making an application Libraries-aware&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;One may wonder what would happen if “my application does not support Libraries.” Let’s imagine an application that, as part of its functionality, needs to save a file to the disk. The application prompts the user with the option to select a location for the file. The user may pick the Documents Library as his save &amp;quot;folder&amp;quot; since this is where the user usual goes when he needs to work on a document. However, if the application doesn’t recognize that the user selected the Documents &lt;b&gt;Library&lt;/b&gt; and not a regular folder, the application may try to save to the Documents Library. This is a problem, since by now, as we already know, that Libraries are non –file system location and therefore can’t be address as regular folders. &lt;/p&gt;  &lt;p&gt;A Library-aware application should include mechanisms for handling situations where users inadvertently try to pick libraries as if they are folder for either saving files to a Library or loading the contents of a Library. Furthermore, most applications allow users to interact with the file system as part of the application experience. An application should provide users with the same familiar entry points and UI offered by the Windows 7 Libraries. By including folders in a Library, users designate where their important data is stored, and thus applications should promote these locations by enabling Library browsing.&lt;/p&gt;  &lt;p&gt;Developers have three integration points with Windows 7 that can help applications become Library-aware. You should review and become familiar with all three points and choose according to your needs.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;The most basic integration method is simply to use the new &lt;i&gt;Common File Dialog&lt;/i&gt; (CFD) for picking files and folders while performing either save or load operations &lt;/li&gt;    &lt;li&gt;The second integration point offers applications the opportunity to Light Up on Windows 7 by enabling applications to select Libraries and &lt;i&gt;consume Libraries&lt;/i&gt; contents. &lt;/li&gt;    &lt;li&gt;The last and most advanced integration point is to stay in sync with Library contents and directly manipulate Libraries by using the new&lt;i&gt; IShellLibrary API &lt;/i&gt;that allows full control over libraries, including creating new libraries. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Let’s start by looking at the basic integration point, which can also be viewed as the bare minimum requirement for application compatibility when working with Windows 7 Libraries. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Using the Common File Dialog (CFD)&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The good news is that Windows 7 Libraries are first class citizens in the CFD, allowing users to browse through Libraries, search Libraries, and even pick a specific Library as a save location, not an actual folder in the Library, but rather the Library itself!&lt;/p&gt;  &lt;p&gt;But (there is always a but), we highly recommended that you use the new CFD interfaces that was introduced with Windows Vista, and not older or customized versions of the CFD. It is &lt;b&gt;very important&lt;/b&gt; to note that the APIs for using the legacy CFD have &lt;b&gt;not&lt;/b&gt; changed since Windows Vista, and XP to support application compatibility. However, the legacy version of the CFD (as is displayed in the next image) doesn’t directly support Libraries or the full new user experience offered in Windows 7.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_5F6C270B.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_08278C55.png" width="351" height="262" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Even if Libraries are presented in the right navigation pane, they require an extra click to save into one of the folders rather than just the Library. Also the legacy CFD doesn’t expose the search and arrangement views functionality that libraries offer. Finally, the legacy CFD doesn’t support the multiple selections of files across several folders, a basic functionality promoted in Libraries. &lt;/p&gt;  &lt;p&gt;Therefore, it is important to use the proper APIs to show the correct CFD version. When using .NET, developers can use either the &lt;i&gt;System.Windows.Forms.FileDialog&lt;/i&gt; or the &lt;i&gt;Microsoft.Win32.FileDialog&lt;/i&gt; namespace. The latter uses the legacy version of the CFD; therefore, .NET developers should always use the WinForms namespace to show the new CFD. The following is a code snippet that prompts the user to choose a save location by showing the common save file dialog as shown in the next image.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;System.Windows.Forms.SaveFileDialog _fd = &lt;br /&gt;        &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; System.Windows.Forms.SaveFileDialog();&lt;br /&gt;_fd.Title = &lt;span style="color: #006080"&gt;&amp;quot;Please choose a location to save your file&amp;quot;&lt;/span&gt;;&lt;br /&gt;_fd.FileName = &lt;span style="color: #006080"&gt;&amp;quot;[Get Folder…]&amp;quot;&lt;/span&gt;;&lt;br /&gt;_fd.Filter = &lt;span style="color: #006080"&gt;&amp;quot;Library|no.files&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (_fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; dir_path = System.IO.Path.GetDirectoryName(_fd.FileName);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (dir_path != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; dir_path.Length &amp;gt; 0)&lt;br /&gt;    { &lt;br /&gt;        &lt;span style="color: #008000"&gt;//this returns the path to the default save location&lt;/span&gt;&lt;br /&gt;        lblResult.Content = dir_path; &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_22F3B261.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_13DCD387.png" width="390" height="315" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Native code developers should use the new family of &lt;i&gt;IFileDialog&lt;/i&gt; native APIs (&lt;i&gt;IFileDialog&lt;/i&gt;, &lt;i&gt;IFileOpenDialog&lt;/i&gt;, &lt;i&gt;IFileSaveDialog&lt;/i&gt;, &lt;i&gt;IFileDialogCustomize&lt;/i&gt;, &lt;i&gt;IFileDialogEvents&lt;/i&gt;, &lt;i&gt;IFileDialogControlEvents&lt;/i&gt;) that are replacing the legacy &lt;i&gt;GetOpenFileName&lt;/i&gt; and &lt;i&gt;GetSaveFileName&lt;/i&gt; APIs from earlier Windows versions. &lt;/p&gt;

&lt;p&gt;The Shell native APIs are COM-based; therefore, before using any COM object we must remember to initialize the COM object by calling &lt;i&gt;CoCreateInstance&lt;/i&gt;. As an example, the following code snippet prompts the user to choose a Library or a folder to save the file to, by showing the common save file dialog.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;*ppsi = NULL;&lt;br /&gt;IFileSaveDialog *pfod;&lt;br /&gt;hr = CoCreateInstance(&lt;br /&gt;            CLSID_FileSaveDialog, &lt;br /&gt;            NULL, &lt;br /&gt;            CLSCTX_INPROC, &lt;br /&gt;            IID_PPV_ARGS(&amp;amp;pfod));&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;{&lt;br /&gt;      hr = pfod-&amp;gt;SetOptions(FOS_PICKFOLDERS);&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;      {&lt;br /&gt;          hr = pfod-&amp;gt;Show(hWndParent);&lt;br /&gt;           &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (SUCCEEDED(hr))&lt;br /&gt;           {&lt;br /&gt;               hr = pfod-&amp;gt;GetResult(ppsi);&lt;br /&gt;           }&lt;br /&gt;    }&lt;br /&gt;    pfod-&amp;gt;Release();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;After initializing the &lt;i&gt;*pfod IFileSaveDialog&lt;/i&gt; variable, we set the dialog options to pick folders by passing the &lt;i&gt;FOS_PICKFOLDERS&lt;/i&gt; flag to the &lt;i&gt;&lt;u&gt;IFileOpenDialog.SetOptions()&lt;/u&gt;&lt;/i&gt;&lt;u&gt;.&lt;/u&gt; This code tells the Open dialog to enable the user to choose folders rather than files, and allows the user to choose a Library. If choosing a library, the CFD will then return the default save location folder that is associated with the chosen Library.&lt;/p&gt;

&lt;p&gt;The two above code snippets are very simple and don’t show any new code; however, it is important to promote consistency among applications running on Windows 7 and supporting Windows 7 Libraries.&lt;/p&gt;

&lt;p&gt;In the next post, we will (finally) show the new Windows 7 library API, as well as how to consume Library contents with the existing Shell APIs.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;br /&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=511856" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Libraries/default.aspx">Libraries</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category></item><item><title>Windows 7 Libraries .NET Sample Library – an Overview</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/04/06/windows-7-libraries-net-sample-library-an-overview.aspx</link><pubDate>Tue, 07 Apr 2009 00:38:37 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:511392</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>28</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=511392</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/04/06/windows-7-libraries-net-sample-library-an-overview.aspx#comments</comments><description>&lt;p&gt;Libraries are the primary entry points to user data in Windows 7. They are the natural evolution from the user’s &lt;a href="http://msdn.microsoft.com/en-us/library/bb776911(VS.85).aspx"&gt;Known Folders&lt;/a&gt;, including those for documents, pictures, music, and videos. However, before jumping into the technicalities, let’s try to explain what a Library in Windows 7 is. A Windows 7 Library is a user-defined collection of content that represents the user’s data independently from the folder hierarchy. Users can unify and flatten the folder hierarchy by aggregating any number of physical locations (on their local machine or on remote machines) into a single view – which is the library. By including folders in Libraries, users tell Windows where their important data are located. In Windows 7 therefore, most applications should use a Library instead of the user’s Known Folders. It is important to note that as Libraries are an integral part of the Windows Shell, they play a greater role in the Windows 7 Explorer user experience. Accordingly, the importance and integration points of Libraries span multiple parts of the Windows Shell, including the Common File Dialog, Folder Picker, and the Windows Explorer Browser control (not Internet Explorer!).&lt;/p&gt;  &lt;p&gt;This is the first post in a series of Library posts. It provides an overview of both the Windows 7 Library functionality and the &lt;a href="http://code.msdn.microsoft.com/Windows7Taskbar/Release/ProjectReleases.aspx?ReleaseId=2246"&gt;Libraries Sample .NET Interop Library&lt;/a&gt;, which is a managed code wrapper and part of the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/03/30/windows-7-net-interop-sample-libraries.aspx"&gt;Windows 7 .NET Interop Sample Libraries&lt;/a&gt;. The second post is all about &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/06/understanding-windows-7-libraries.aspx"&gt;Understanding Windows 7 Libraries&lt;/a&gt;. In future posts, we will dive into the internal implementation of Libraries as well as how to use the Libraries programming model and APIs. &lt;/p&gt;  &lt;p&gt;If you are unfamiliar with and haven’t seen any demonstrations of the updated Windows 7 Shell and Libraries in action, I suggest you watch the &lt;a href="http://beta.channel9.msdn.com/posts/Dan/Windows-7-Find-and-Organize-Part-1-The-User-Experience/"&gt;Windows 7: Find and Organize Part 1&lt;/a&gt; webcast on Channel 9. This will give you some context for the technical material we cover here.&lt;/p&gt;  &lt;p&gt;Let’s review the &lt;b&gt;&lt;i&gt;Windows 7 Libraries .NET Interop Sample Library&lt;/i&gt;&lt;/b&gt; architecture and note the important classes. Please remember that the Libraries sample is &lt;b&gt;&lt;u&gt;part&lt;/u&gt;&lt;/b&gt; of the Taskbar and Libraries assembly. Since both Taskbar and the Libraries share many common integration points with the Windows Shell, it makes sense to have them grouped together and use the same Shell structures and methods. &lt;/p&gt;  &lt;p&gt;Opening the solution reveals the following structure:&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="571"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="281"&gt;         &lt;ul&gt;           &lt;li&gt;The Demos folder containing several demo projects that show the various aspects of &lt;b&gt;both&lt;/b&gt; the &lt;i&gt;Taskbar&lt;/i&gt; and &lt;b&gt;&lt;i&gt;Libraries&lt;/i&gt;&lt;/b&gt; wrappers as you can see from the image; we will focus on the Libraries &lt;/li&gt;            &lt;li&gt;The Wrappers folder containing the &lt;i&gt;Windows7.DesktopIntegration&lt;/i&gt; assembly, which is the main manager API for &lt;b&gt;both&lt;/b&gt; the Taskbar and &lt;b&gt;Libraries&lt;/b&gt; &lt;/li&gt;            &lt;li&gt;A modified version of the &lt;a href="http://code.msdn.microsoft.com/VistaBridge"&gt;Vista Bridge Sample Library&lt;/a&gt; - We based our code on the 1.4 version. And as mentioned before, the Windows Vista bridge Project will be superseded by the new Windows API Code Pack for the .NET Library &lt;/li&gt;         &lt;/ul&gt;       &lt;/td&gt;        &lt;td valign="top" width="288"&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_76A48BD4.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_74878D0B.png" width="276" height="308" /&gt;&lt;/a&gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Let’s take a quick look at the main class that enables developers to take advantage of the new Library functionality. The ShellLibrary.cs file contains the ShellLibrary class, which is the main entry point for managed code developers. Using the ShellLibrary, developers can programmatically perform all Library operations, including:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create new library &lt;/li&gt;    &lt;li&gt;Load existing library &lt;/li&gt;    &lt;li&gt;Delete library &lt;/li&gt;    &lt;li&gt;Add / remove folders from the library &lt;/li&gt;    &lt;li&gt;Set the default save location of the library &lt;/li&gt;    &lt;li&gt;Set the folder type &lt;/li&gt;    &lt;li&gt;Show the library management dialog box &lt;/li&gt;    &lt;li&gt;Set the library icon &lt;/li&gt;    &lt;li&gt;Pin and unpin the library from the left navigation pan in Windows Explorer &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt; The demos in the Libraries folder highlight all the above-mentioned Library functionality. Let’s review them:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The &lt;i&gt;LibraryManagerDemo&lt;/i&gt; is a Windows Presentation Foundation (WPF) application that showcases all the functionality offered by libraries. It is a very simple application that offers developers a great opportunity to review all the above-mentioned Libraries functionality.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image7_5F00_3C70CFEC.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image7_5F00_thumb_5F00_32C861B6.png" width="550" height="391" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The &lt;strong&gt;&lt;em&gt;SLUtil&lt;/em&gt;&lt;/strong&gt; (not Silverlight) is a command line interface that allows users and developers to manage their Libraries. Again, it offers all the above-mentioned Libraries functionality. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image13_5F00_519ED594.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image13_5F00_thumb_5F00_1B4DAD85.png" width="550" height="232" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here are some additional resources for programming Windows 7 Libraries: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Download Documentation and samples from the &lt;a href="http://code.msdn.microsoft.com/Windows7Taskbar"&gt;Windows 7 Libraries: Developer Resources&lt;/a&gt; page on MSDN. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;View Channel 9 videos:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://channel9.msdn.com/posts/Dan/Windows-7-Find-and-Organize-Part-1-The-User-Experience/"&gt;Windows 7: Find and Organize Part 1 The User Experience&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/pdc2008/PC16/"&gt;Windows 7: Empower users to find, visualize and organize their data with Libraries and the Explorer&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Additional blog posts&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/04/06/understanding-windows-7-libraries.aspx"&gt;Understanding Windows 7 Libraries&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/alon/"&gt;Alon Fliess&lt;/a&gt; contributed to this post&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=511392" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7+for+Developers+Blog/default.aspx">Windows 7 for Developers Blog</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Libraries/default.aspx">Libraries</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category></item><item><title>Windows 7 Taskbar .NET Sample Library – an Overview</title><link>http://windowsteamblog.com/blogs/developers/archive/2009/04/03/windows-7-taskbar-net-sample-library-an-overview.aspx</link><pubDate>Fri, 03 Apr 2009 07:32:29 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:511258</guid><dc:creator>Yochay Kiriaty</dc:creator><slash:comments>40</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://windowsteamblog.com/blogs/developers/rsscomments.aspx?PostID=511258</wfw:commentRss><comments>http://windowsteamblog.com/blogs/developers/archive/2009/04/03/windows-7-taskbar-net-sample-library-an-overview.aspx#comments</comments><description>&lt;p&gt;One of the first noticeable changes in Windows 7 Desktop is the new Taskbar. &lt;a href="http://blogs.msdn.com/e7/archive/2008/11/20/happy-anniversary-windows-on-the-evolution-of-the-taskbar.aspx"&gt;The Windows 7 Taskbar&lt;/a&gt; post on the E7 blog clearly documents the reasons driving the Windows 7 Taskbar look and feel. The Windows 7 taskbar introduces new functionality that developers need to understand in order for them to take full advantage of it in their own applications and enhance their end users’ experiences. The Windows 7 Taskbar is an application-launching and window-switching mechanism that consolidates the functionalities from previous Windows Desktop mechanisms such as Quick Launch, Recent Documents, Notification area icons, desktop shortcuts, and running application windows.&lt;/p&gt;  &lt;p&gt;If you are unfamiliar with and haven’t seen any demonstrations of the Windows 7 Taskbar, please watch the &lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-New-Taskbar-an-overview/"&gt;Windows 7 Taskbar Overview&lt;/a&gt; webcast on Channel 9. This will give you some context for the technical material we cover here.&lt;/p&gt;  &lt;p&gt;This is the first post in a series of Taskbar posts. It provides an overview of both the new Taskbar functionality and the &lt;a href="http://code.msdn.microsoft.com/Windows7Taskbar/Release/ProjectReleases.aspx?ReleaseId=2246"&gt;Taskbar and Libraries Sample .NET Interop Library&lt;/a&gt;, which is a managed code wrapper and part of the &lt;a href="http://windowsteamblog.com/blogs/developers/archive/2009/03/30/windows-7-net-interop-sample-libraries.aspx"&gt;Windows 7 .NET Interop Sample Libraries&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Let’s review the &lt;b&gt;&lt;i&gt;Windows 7 Taskbar and Libraries .NET Interop Sample Library&lt;/i&gt;&lt;/b&gt; architecture and note the important classes. Opening the solution reveals the following structure:&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="549"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="258"&gt;         &lt;ul&gt;           &lt;li&gt;A modified version of the &lt;a href="http://code.msdn.microsoft.com/VistaBridge"&gt;Vista Bridge Sample Library&lt;/a&gt; - We based our code on the 1.4 version. And as mentioned before, the Windows Vista bridge Project will be superseded by the new Windows API Code Pack for the .NET Library &lt;/li&gt;            &lt;li&gt;The Demos folder containing several demo projects that show the various aspects of both the Taskbar and Libraries wrappers as you can see from the image &lt;/li&gt;            &lt;li&gt;The Wrappers folder containing the &lt;i&gt;Windows7.DesktopIntegration&lt;/i&gt; assembly, which is the main manager API for both the Taskbar and Libraries &lt;/li&gt;         &lt;/ul&gt;       &lt;/td&gt;        &lt;td valign="top" width="289"&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_2A8A4133.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_3717EE4F.png" width="286" height="361" /&gt;&lt;/a&gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Let’s take a quick look at the main classes that enable developers to take advantage of the new taskbar functionality:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The &lt;em&gt;Windows7Taskbar&lt;/em&gt; class provides low-level facilities for manipulating the process-wide and window-specific application IDs, controlling custom window preview bitmaps, setting the Taskbar overlay icon and progress bar, and clipping the Taskbar thumbnail &lt;/li&gt;    &lt;li&gt;The &lt;i&gt;JumpListManager&lt;/i&gt; class provides an abstraction of the application’s jump list, including facilities to manipulate custom destinations, user tasks, the Recent and Frequent lists, and items removed by the user &lt;/li&gt;    &lt;li&gt;The &lt;i&gt;ThumbButtonManager&lt;/i&gt; class provides an abstraction of the Taskbar thumbnail toolbar, including the facilities to create thumbnail toolbar buttons and receive notifications when they are clicked &lt;/li&gt;    &lt;li&gt;The &lt;i&gt;CustomWindowsManager&lt;/i&gt; class provides an abstraction of a customized window thumbnail preview and live preview (peek), including the facilities to receive a notification when a preview bitmap is requested by the Desktop Window Manager (DWM), and to automatically grab the preview bitmap of a window &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The Taskbar demos showcase all of the above-mentioned Taskbar functionality. Let’s review them:&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;MainDemo&lt;/strong&gt; sample is a simple WinForm application that showcases all the functions that are expose via the API, including building a jump list with custom categories and custom tasks, setting an overlay icon and progress bar, and creating and handling events from Thumbnail Toolbar buttons:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_3CF291E8.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_2D034D24.png" width="522" height="377" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In order for the main demo application to run properly, you will need to register this application as a registered handler for text files (*.txt). By registering this application and a handler for text files, you ensure that each time you open a text file directly from Windows Explorer. Windows automatically calls &lt;b&gt;&lt;i&gt;SHAddToRecentDocs&lt;/i&gt;&lt;/b&gt; on your application's behalf. This inserts the item in the Windows Recent list and eventually into the Jump List Recent Category. The same automatic behavior occurs when using the Windows &lt;b&gt;common file dialog&lt;/b&gt; to open files through our applications. &lt;/p&gt;  &lt;p&gt;You can register the application from the Administrative tool strip menu.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;DocumentReader &lt;/strong&gt;sample demonstrates how developers can provide better Taskbar Thumbnail preview experiences for their users by clipping and customizing the Thumbnail Preview.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_593FD408.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_5722D53F.png" width="628" height="491" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;IMClient &lt;/strong&gt;sample demonstrates how Taskbar overlay icons and Taskbar progress bars can light up an application’s Taskbar button instead of relying on an additional dialog or on an icon in the system notification area (the tray). It is important to note that in Windows 7, the notification area has undergone a few changes and now shows the least number of icons in order to keep the taskbar clean and reduce the number of balloon notification messages.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_674E9D38.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_1B16938A.png" width="469" height="216" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The last demo, &lt;strong&gt;WebBrowser&lt;/strong&gt;&lt;em&gt;,&lt;/em&gt; demonstrates how to customize both the Thumbnail previews and the window preview (AeroPeek), and display internal tabs. As you can see from the following images, we can override the default behavior by flipping the images and adding some text on top of the preview image.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_4BC99B35.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers/image_5F00_thumb_5F00_5F0A51D4.png" width="591" height="605" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here are some additional resources for programming the Windows 7 Taskbar: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Download Documentation and samples from the &lt;a href="http://code.msdn.microsoft.com/Windows7Taskbar"&gt;Windows 7 taskbar: Developer Resources&lt;/a&gt; page on MSDN.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Channel 9 videos:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Designing-the-Windows-7-Taskbar/"&gt;Designing the Windows 7 Taskbar&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-Taskbar-Behind-the-Scenes/"&gt;Windows 7 Taskbar - Behind the Scenes&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Jump-into-the-Windows-7-Taskbar-Jump-Lists/"&gt;Jump into the Windows 7 Taskbar Jump Lists&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/posts/yochay/Windows-7-New-Taskbar-an-overview/"&gt;Windows 7 Taskbar Overview&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Sasha Goldstein contributed to this blog - &lt;a title="http://blogs.microsoft.co.il/blogs/sasha/archive/2009/02/12/windows-7-taskbar-apis.aspx" href="http://blogs.microsoft.co.il/blogs/sasha/archive/2009/02/12/windows-7-taskbar-apis.aspx"&gt;http://blogs.microsoft.co.il/blogs/sasha/archive/2009/02/12/windows-7-taskbar-apis.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowsteamblog.com/aggbug.aspx?PostID=511258" width="1" height="1"&gt;</description><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Developers/default.aspx">Developers</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/.NET/default.aspx">.NET</category><category domain="http://windowsteamblog.com/blogs/developers/archive/tags/Sample+Code/default.aspx">Sample Code</category></item></channel></rss>