The Windows 7 Shell populates and manages the Recent and Frequent destination categories.
Simple mechanisms govern the definition of what a recent or frequent item might be and performing integration tasks with these mechanisms does not require any interaction with
taskbar-specific APIs.
If your application has a well-defined file type, your application’s installer should register this
file type to associate it with your application. This association is recorded in the Windows 7
registry, under the HKEY_CLASSES_ROOT registry hive. Even if your application is not the
primary handler for the file type (for example, Microsoft Visual Studio can open XML
documents, but it’s not necessarily the primary handler for .xml files), you should still associate
it with file types that it can open.
Associating Your Application with a File Type
To associate your application with a file type, you need to fill the registry entries under
the HKEY_CLASSES_ROOT registry hive. Specifically, you need to create a key with your
file extension (for example, .xml) and a subkey called OpenWithProgIds. Within the
subkey, create a string value with your ProgID in the standard ProgID format (for
example, VisualStudio.9.0).
Note The following MSDN page offers a detailed walkthrough of this process:
http://msdn.microsoft.com/en-us/library/cc144148(VS.85).aspx. Additionally, you might find
useful the Windows 77.DesktopIntegration.RegistrationHelper utility, which performs the
necessary steps to register a file type association in the Windows 7 registry. (The utility is
available as part of the Windows 7 7 Taskbar Sample Library.)
Next, create another key under the HKEY_CLASSES_ROOT registry hive with the name of
the ProgID used in the previous steps. Under that key, add subkeys to form the
following path: shell\Open\Command. Within the Command subkey, add a default string
value with the full path to your executable and additional command-line parameters if
desired. Within the command-line string, you can use the %1 placeholder, which the
Windows 7 Shell replaces with the name of the document being opened. The following
screen shot is an example of a registry association for the .ascx file extension with the
Visual Studio ProgID.
If you successfully followed these steps, the Windows 7 Shell recognizes your application
as a handler for the specified file type. Successful completion of these steps enables
users to launch your application by double-clicking items with your file extension in
Windows 7 Explorer, and it enables you to embed destinations in your application’s
Jump List.

The Windows 7 Shell adds items to the Recent and Frequent lists for your application when one
of the following actions occurs:
- The item is used to launch your application directly for example, when you double-click
a file or a shortcut in Windows 7 Explorer.
- The item is selected by a user in a common file dialog (Open or Save).
- The item is passed as a parameter to the SHAddToRecentDocs function, which is part of
the Windows 7 Shell API.
Note Common file dialogs provide a standard look and feel as well as additional functionality to
Open and Save operations throughout the Windows 7 Shell. Applications that use the common file
dialogs will always benefit from the latest version of the user interface provided by the underlying
operating system (regardless of the version of Windows 7 they were compiled on). Taking advantage
of Windows 7 Shell Libraries and of Recent and Frequent categories is greatly simplified if you use
common file dialogs in your application. For more information about common file dialogs, consult
the MSDN documentation.
The first two actions do not require any interaction on your application’s behalf the
Windows 7 Shell automatically maintains the Recent and Frequent item lists for your
application. Therefore, if your Jump List contains the Recent or Frequent destination category
and your application is registered as a handler for some file type, the application’s Jump List
automatically contains recently or frequently accessed items. If you choose to notify the Windows 7 Shell directly, you can use the SHAddToRecentDocs
Win32 API or the managed equivalent the JumpList.AddToRecent method which is part of
the Windows 7 API Code Pack. This has the same effect as populating the Jump List with the
recently or frequently accessed items.
The only thing left to do, then, is to let the taskbar know that your application requires a
Jump List with one of the system destination categories Recent or Frequent. Remember that
to display the Jump List correctly and associate it with the appropriate taskbar button, you
need to set the window application ID (or the process application ID) to the same consistent
value you use throughout your application.
If you decide to use the Recent destination category, you don’t need to do anything else to
get the Jump List to work. However, if you want to use the Frequent destination category, you
need to follow through with a list-building transaction. The following code sample, which
displays both the native and managed APIs, shows how to create a Jump List for an
application, add to it the Frequent destination category, and ensure that it’s populated with
one recently used item:
//C++:
ICustomDestinationList* pJumpList = NULL;
if (FAILED(CoCreateInstance(
CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pJumpList))))
goto Cleanup;
if (FAILED(pJumpList->SetAppID(L"Microsoft.Samples.MyApplication")))
goto Cleanup;
UINT uMaxSlots;
IObjectArray* pRemoved;
if (FAILED(pJumpList->BeginList(&uMaxSlots, IID_PPV_ARGS(&pRemoved))))
goto Cleanup;
if (FAILED(pJumpList->AppendKnownCategory(KDC_FREQUENT)))
goto Cleanup;
if (FAILED(pJumpList->CommitList()))
goto Cleanup;
Cleanup:
if (pJumpList != NULL)
pJumpList->Release();
//C#:
JumpList jumpList = JumpList.CreateJumpList();
jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Frequent;
jumpList.AddToRecent("MyFile.ext");
jumpList.Refresh();
After completing these steps, your application will have a Jump List with the Recent or
Frequent category enabled. If your users are using Windows 7 Explorer to launch your
application from individual items, and if you’re using the common file dialogs for Open and
Save functionality, there’s nothing else you need to do to manage the Recent and
Frequent categories.
It usually doesn’t make sense to include both the Recent and Frequent categories in the
same Jump List. It is recommended that you choose one or the other. |