Editor’s Note:
This article was originally written in February 2010, and at the time the released version of .Net (version 3.5) did not implement features new to Windows 7. These features are now accessible in .Net 4.0 which has since been released with Visual Studio 2010 but require the use of WPF, which means if you’re planning on staying with Windows Forms this is probably the only method still open to you. I hope to cover accessing Windows 7 features via WPF in the future.
Since its release, Windows 7 has had a very strong uptake with consumers across the globe (that is, in comparison with other operating systems in the past). This should come as no surprise to anyone, as Windows 7 is pretty awesome.
Windows 7 introduces tons of new features which are pretty cool individually, but together add up to a huge improvement over its predecessors. One of the coolest of these features – or at least the one that had the most media attention – is the new task bar.
There are a lot of new components introduced with the new taskbar, but for the purposes of this article, I’m only going to focus on Jump Lists; further on I plan to talk about progress bars in taskbar buttons, and image overlays on taskbar buttons, but those will be in future posts. These features are particularly handy for 3rd party developers and I’ve noticed a lot of people looking for ways to access them in the .Net environment.
There are two primary approaches to this problem; since both have their merits, I’ll focus on one, then the other.
Since the current version of .Net (at the time I wrote this, version 3.5) has been around well before the release of Windows 7, it’s certainly no surprise that these features are not directly supported by the .Net Framework. However, luckily for us, Microsoft has provided a library for accessing these features in .Net, which is basically a wrapper for part of the new Windows API. You can download the latest version here:
http://code.msdn.microsoft.com/WindowsAPICodePack
Just in case that link breaks in the future, I’ve also uploaded version 1.0.1 of the code pack here:
http://files.nacimota.com/WindowsAPICodePack101.zip
The code pack is actually distributed as source code instead of binaries. While we could include the source in our solution, I find it much simpler and cleaner to build the DLLs then use them as references in our project, so let’s do that.
After extracting everything in the ZIP archive to a folder of your choice, enter the WindowsAPICodePack folder and open WindowsAPICodePack.sln in either Visual C# Express 2008 or Visual Studio 2008 (you can open it in future versions but you will be required to upgrade the solution first).
Once the solution is open, click Build > Build Solution. Binaries for each project in the solution should have been compiled and can now be found in the \bin\Debug subdirectory of each project directory in the code pack.
You can now close the solution and open/create your own project. I’m going to create a .Net 3.5 Windows Forms application in Visual C# Express; I’ve called it Taskbar Fun.
In the Solution Explorer, right click on References and select Add Reference…
Since Visual Studio isn’t yet aware of the libraries we want to reference, we need to select the browse tab and locate them manually. Browse to the directory where you extracted the code pack and select the following binaries from WindowsAPICodePack\Shell\bin\Debug:
Microsoft.WindowsAPICodePack.dll
Microsoft.WindowsAPICodePack.Shell.dll
Then click OK to add references to those binaries.
Next, head over to the code for our default form (by default, it should be called Form1.cs), since this is where we will add our Windows 7 magic. Add the following directives to the top of the file so we can access the namespaces in the libraries without typing them over and over:
using Microsoft.WindowsAPICodePack; using Microsoft.WindowsAPICodePack.Shell; using Microsoft.WindowsAPICodePack.Taskbar;
You can also rename the file and class to something more appropriate if it pleases you. I’m just going to call mine MainForm.
Create a JumpList object at the start of the class. We’ll initialize our JumpList in the form’s Shown event, so create that event and the necessary handler now.
namespace TaskbarFun
{
public partial class MainForm : Form
{
private JumpList jumplist;
public MainForm()
{
InitializeComponent();
this.Shown += new EventHandler(MainForm_Shown);
}
void MainForm_Shown(object sender, EventArgs e)
{
// stuff goes here
}
}
}
Inside our event handler, set the value of the JumpList object to JumpList.CreateJumpList(). This does some basic initialization stuff with our JumpList like associating it with our application. Before we can actually see our jump list, we’re obviously going to have to add some items. Let’s start with a JumpListLink, which is essentially just a windows shortcut. For my JumpListLink, I’m going to create a shortcut to Notepad. The constructor of the JumpListLink class demands a path and a title. Notepad is located in system32 directory; the title is completely arbitrary.
void MainForm_Shown(object sender, EventArgs e)
{
jumplist = JumpList.CreateJumpList();
JumpListLink notepadlink = new JumpListLink("C:\\Windows\\system32\\notepad.exe", "Open Notepad");
}
Next, we need to add our JumpListLink object to our JumpList, then update taskbar so that our changes are visible. Items are added to a JumpList using the JumpList.AddUserTasks() method. To update the actual jump list in the tasbar using our JumpList object, call the JumpList .Refresh() method.
void MainForm_Shown(object sender, EventArgs e)
{
jumplist = JumpList.CreateJumpList();
JumpListLink notepadlink = new JumpListLink("C:\\Windows\\system32\\notepad.exe", "Open Notepad");
jumplist.AddUserTasks(notepadlink);
jumplist.Refresh();
}
If you build your solution now you will see that the jump list works and we have our Open Notepad link. You’ll see the process is listed as vshost.exe instead of whatever your project name is; this is normal, of course.

You can also add separators by creating JumpListSeparator objects and adding them with the same method:
void MainForm_Shown(object sender, EventArgs e)
{
jumplist = JumpList.CreateJumpList();
JumpListLink notepadlink = new JumpListLink("C:\\Windows\\system32\\notepad.exe", "Open Notepad");
JumpListSeparator separator = new JumpListSeparator();
JumpListLink paintlink = new JumpListLink("C:\\Windows\\system32\\mspaint.exe", "Open Paint");
jumplist.AddUserTasks(notepadlink, separator, paintlink);
jumplist.Refresh();
}
I’ll be focusing on other features like progress bars and icon overlays in future posts.

