Windows 7 Taskbar — Application ID

By now, Win­dows 7 is almost old news and most of you would have been using or at least seen Win­dows 7 and one of the first things that should have caught your atten­tion is the redesigned task bar.

The new task bar are visu­al­ly much more pleas­ant and func­tion­al­ly it has also intro­duced a num­ber of rather use­ful new fea­tures such as the ‘jump list’ and the abil­i­ty to dis­play the progress bar on the task bar icon itself! In addi­tion, mul­ti­ple run­ning instances of the same appli­ca­tion is grouped togeth­er and when you hov­er over the icon you get a pre­view of each instance (see below).

image

The task bar works out which win­dows to group togeth­er by using the Appli­ca­tion User Mod­el IDs (referred to as AppIDs from here on). In most cas­es you can rely on the AppID assigned to a process by the sys­tem. How­ev­er, an appli­ca­tion that owns mul­ti­ple process­es or an appli­ca­tion that is run­ning in a host process might need to explic­it­ly iden­ti­fy itself so that it can group its oth­er­wise dis­parate win­dows under a sin­gle taskbar but­ton and con­trol the con­tents of that application’s jump list.

Sup­port for the new task bar fea­tures is not includ­ed in the core .Net frame­work, you need to down­load the lat­est Win­dows API Code Pack (see Ref­er­ences sec­tion), build the solu­tion and ref­er­ence these two dlls in your project:

Microsoft.WindowsAPICodePack.dll

Microsoft.WindowsAPICodePack.Shell.dll

It takes only one line of code to set the AppID of a new win­dow, how­ev­er, it pays to write safe code that won’t break out­side Win­dows 7 so your code will usu­al­ly look more like this:

// Check whether the taskbar feature is supported (Win 7 or Win Server 2008 R2)
if (TaskbarManager.IsPlatformSupported)
{
    // Set the AppID for the current process TaskbarManager.Instance represents an 
    // instance of the Windows Taskbar
    TaskbarManager.Instance.ApplicationId = "NewApplicationID";
}

References:

Win­dows­API Code Pack

Windows7 Train­ing Kit for Devel­op­ers