65.9K
CodeProject is changing. Read more.
Home

Anatomy of the Windows 7 taskbar – Jumplist (Part 2)

starIconstarIconstarIconstarIconemptyStarIcon

4.00/5 (1 vote)

Apr 1, 2010

CPOL
viewsIcon

10638

If your application is associated with a specific file extension, then you get the last part for free! The taskbar also lists files opened by your application in the Recent category!

If your application is associated with a specific file extension, then you get the last part for free! The taskbar also lists files opened by your application in the Recent category!

To check if your file extension is associated with your application, open your registry editor and navigate to HKEY_CLASSES_ROOT and search for your extension!

Here is a code snippet to check:

RegistryKey openWithKey = Registry.ClassesRoot.OpenSubKey
		(Path.Combine(".wpost", "OpenWithProgIds")); 
string value = openWithKey.GetValue(progId, null) as string; 

if (value == null) 
{ 
   // No extension registered 
} 
else 
{ 
   // File extension is registered 
}

Registering a file extension is extremely easy using the RegistrationHelper:

string executablePath = Assembly.GetEntryAssembly().Location; 

RegistrationHelper.RegisterFileAssociations( 
   "LiveWriter", 
   false, 
   "LiveWriter", 
   executablePath + " /doc %1", 
   ".wpost");

To manually report file usage to shell, call AddToRecent:

jumpList.AddToRecent(fileName);

Note: The dialog box automatically reports usage to shell, but it's still recommended that the user explicitly call AddToRecent. Shell will automatically handle duplicate additions.

And that’s it…