February 11th, 2011

How do specify that a shortcut should not be promoted as newly-installed on the Start menu?

Windows XP employed a number of heuristics to determine which Start menu shortcuts should be promoted when an application is newly-installed. But what if those heuristics end up guessing wrong?

You can set the System.App­User­Model.Exclude­From­Show­In­New­Install property to VARIANT_TRUE to tell the Start menu, “I am not the primary entry point for the program; I’m a secondary shortcut, like a help file.”

#include <windows.h>
#include <tchar.h>
#include <shlobj.h>
#include <atlbase.h>
// class CCoInitialize incorporated here by reference
int __cdecl _tmain(int argc, TCHAR **argv)
{
 // error checking elided for expository purposes
 CCoInitialize init;
 CComPtr<IShellLink> spsl;
 spsl.CoCreateInstance(CLSID_ShellLink);
 spsl->SetPath(TEXT("C:\\Program Files\\LitWare\\LWUpdate.exe"));
 PROPVARIANT pvar;
 pvar.vt = VT_BOOL;
 pvar.boolVal = VARIANT_TRUE;
 CComQIPtr<IPropertyStore>(spsl)->SetValue(PKEY_AppUserModel_ExcludeFromShowInNewInstall, pvar);
 CComQIPtr<IPersistFile>(spsl)->Save(L"LitWare Update.lnk", TRUE);
 return 0;
}
Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.