一名热爱体感技术的
业余专业开发人员

XP下无法通过代码修改开始菜单锁定栏(才怪)

微软的解释 Why is there no programmatic access to the Start menu pin list?

相关文章 Registry Settings for the Start Menu in Windows XP

不过,最后还是找到了特殊的方法实现,囧。见最后吧:

We learned our lesson the hard way.

In Windows 95, we gave programmatic access to the Start menu “Fast items” list – the items that appear at the top of the Start menu above the Programs list. This area was meant for the user to customize with their favorite links, but programs quickly saw the opportunity and spammed themselves into it every chance they got.

In IE, we gave programmatic access to the Favorites menu, and once again, programs spammed themselves into it.

In Windows XP we intentionally did not give programmatic access to the bold list of items at the top of the Start menu (the “pin list”). The pin list is for users to put their favorite icons. It is not the place for a program to decide unilaterally, “I am so cool. I am your favorite icon. I just know it. So I’ll put myself there because, well, I’m so cool.”

Because we knew that the moment we let people mess with the pin list, everybody would install themselves into it and it would become meaningless (and annoying).

What’s particularly galling are the programs that, as part of their install, decide that they are so cool they want to be everywhere to make sure you don’t miss out on the coolest most amazing program ever written in the history of mankind, so they go into the Start menu, into the Fast items, onto the desktop, into the Quick Launch, onto your Favorites, take over as your default autoplay handler, and even hang out as an icon next to the clock on the taskbar just in case you somehow missed all those other places – and each time you run them, they go and recreate those icons and settings in case you “accidentally lost them”.

I hate those programs.


  • Policy:Disable the new simple Start Menu
  • Policy:Remove pinned programs list from the Start menu
  • Policy:Remove frequent programs list from the Start Menu
  • Policy:Remove More Programs list from the Start menu
  • Policy:Remove common program groups from Start Menu
  • Policy:Gray unavailable Windows Installer programs Start Menu shortcuts
  • Policy:Disable and remove links to Windows Update
  • Policy:Remove user folders from the Start Menu
  • Policy:Prohibit user from changing user folder paths
  • Policy:Remove My Documents folder from the Start Menu
  • Policy:Prohibit user from changing My Documents path
  • Policy:Remove Recent Documents item from Start Menu
  • Policy:Maximum number of recent documents
  • Policy:Clear history of recent documents on exit
  • Policy:Remove Favorites item from Start Menu
  • Policy:Remove My Computer from the Start Menu
  • Policy:Remove Network Connections from the Start Menu
  • Policy:Remove Network Places from the Star

You can use the Group Policy editor, gpedit.msc, to manage XP Start Menu options:User Configuration \ Administrative Templates \ Start Menu and Taskbar

You can also set them directly via the registry using the registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer

The registry entries are DWORD values. A value of 1 is enabled, and a value of 0 is disabled:

  • Policy: Disable the new simple Start Menu
    Description:Disables the new simple Start menu and forces the classic Start menu.
    Registry Value: NoSimpleStartMenu
  • Policy: Remove pinned programs list from the Start menu
    Description:Removes the pinned programs list from the Start menu. Also removes the Internet and E-mail checkboxes from the Start menu customization CPL.
    Registry Value: NoStartMenuPinnedList
  • Policy:Remove frequent programs list from the Start Menu
    Description:Removes the frequently-used programs list from the Start menu.
    Registry Value: NoStartMenuMFUprogramsList
  • Policy:Remove More Programs list from the Start menu
    Description:Removes the More Programs list from the Start menu.
    Registry Value: NoStartMenuMorePrograms
  • Policy:Remove common program groups from Start Menu
    Description:Removes items in the All Users profile from the More Programs list on the Start menu.
    Registry Value: NoCommonGroups
  • Policy:Gray unavailable Windows Installer programs Start Menu shortcuts
    Description:Displays partially installed programs in gray text on the Start menu.
    Registry Value: GreyMSIAds
  • Policy:Disable and remove links to Windows Update
    Description:Removes the Windows Update link from the More Programs list in Start menu, from the Tools menu in IE, and blocks user access to windowsupdate.Microsoft.com.
    Registry Value: NoWindowsUpdate
  • Policy:Remove user folders from the Start Menu
    Description:Removes all user-specific folders except My Documents (My Pictures, My Music, Favorites, and Recent Documents) from the Start menu. Also removes the corresponding checkboxes from the Start menu customization CPL.
    Registry Value:This is a combination of the following: NoStartMenuMyMusic , NoSMMyPictures , NoFavoritesMenu , NoRecentDocsMenu
  • Policy:Prohibit user from changing user folder paths
    Description:Prevents users from changing the path to the My Pictures, My Music, Favorites, and Recent Documents folders.
    Registry Value: DisableMyPicturesDirChange , DisableMyMusicDirChange , DisableFavoritesDirChange .
  • Policy:Remove My Documents folder from the Start Menu
    Description:Removes My Documents folder from the Start menu and corresponding checkbox from the Start menu customization CPL.
    Registry Value: NoSMMyDocs
  • Policy:Prohibit user from changing My Documents path
    Description:Prevents users from changing the path to the My Documents folder.
    Registry Value: DisablePersonalDirChange
  • Policy:Remove Recent Documents item from Start Menu
    Description:Removes the Recent Documents folder from the Start menu. Also removes the corresponding checkbox from the Start menu customization CPL.
    Registry Value: NoRecentDocsMenu
  • Policy:Maximum number of recent documents
    Description:Specifies the number of shortcuts displayed on the Recent Documents submenu.
    Registry Value: MaxRecentDocs
  • Policy:Clear history of recent documents on exit
    Description:Deletes all shortcuts shown in the Recent Documents menu when the user logs off.
    Registry Value: ClearRecentDocsOnExit
  • Policy:Remove Favorites item from Start Menu
    Description:Prevents users from adding the Favorites item to the Start menu. Also removes the corresponding checkbox from the Start menu customization CPL.
    Registry Value: NoFavoritesMenu
  • Policy:Remove My Computer from the Start Menu
    Description:Removes the My Computer item from the Start Menu and the corresponding checkbox from the Start menu customization CPL.
    Registry Value: {20D04FE0-3AEA-1069-A2D8-08002B30309D} under HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\NonEnum.
  • Policy:Remove Network Connections from the Start Menu
    Description:Removes the Network Connections item from the Start menu and the corresponding checkbox from the Start menu customization CPL.
    Registry Value: NoNetworkConnections
  • Policy:Remove Network Places from the Start Menu
    Description:Removes the Network Places item from the Start menu and the corresponding checkbox from the Start menu customization CPL.
    Registry Value: NoStartMenuNetworkPlaces
  • Policy:Do not add shares of recently used documents to Network Places
    Description:Remote shared folders are not added to Network Places whenever you open a document in the shared folder.
    Registry Value: NoRecentDocsNetHood
  • Policy:Remove Help item from Start Menu
    Description:Removes the Help item from the Start menu, but does not disable Help files from running.
    Registry Value: NoSMHelp
  • Policy:Remove Search item from Start Menu
    Description:Removes the Search item from the Start menu and disables some Windows Explorer search elements.
    Registry Value: NoFind
  • Policy:Remove Run item from Start Menu
    Description:Removes the ability to execute programs from the Run option on the Start menu, Task Manager, or by pressing Winkey + R. Also removes the corresponding checkbox from the Start menu customization CPL.
    Registry Value: NoRun
  • Policy:Add “Run in Separate Memory Space” check box to Run dialog box
    Description:Allows 16-bit programs to run in a dedicated Virtual DOS Machine (VDM) process.
    Registry Value: MemCheckBoxInRunDlg
  • Policy:Do not use the search-based method when resolving shell shortcuts
    Description:Prevents the system from conducting a comprehensive search of the target drive to resolve a shortcut.
    Registry Value: NoResolveSearch
  • Policy:Do not use the tracking-based method when resolving shell shortcuts
    Description:Prevents the system from using NTFS features to resolve a shortcut.
    Registry Value: NoResolveTrack
  • Policy:Force Logoff to the Start Menu
    Description:Forces the Logoff button to the Start menu and prevents users from removing the Logoff option from the Start menu.
    Registry Value: ForceStartMenuLogoff
  • Policy:Disable Logoff on the Start Menu
    Description:Removes the “Logoff” button from the Start menu and prevents users from adding the Logoff button to the Start menu.
    Registry Value: StartMenuLogoff
  • Policy:Disable and remove the Turn Off Computer button
    Description:Removes the “Turn Off Computer” button from the Start Menu and prevents shutting down Windows using the standard shutdown user interface.
    Registry Value: NoClose
  • Policy:Disable and remove the Undock PC command
    Description:Removes the “Undock PC” button from the Start Menu and prevents undocking of the PC (laptop).
    Registry Value: NoStartMenuEjectPC
  • Policy:Disable drag-and-drop menus on the Start Menu
    Description:Prevents users from modifying the Start menu by dragging and dropping items. Other methods of customizing the Start menu are still enabled.
    Registry Value: NoChangeStartMenu
  • Policy:Disable changes to Taskbar and Start Menu settings
    Description:Removes the Taskbar & Start Menu item from the Control Panel, and removes the Properties item from the Start menu (and button) context menu.
    Registry Value: NoSetTaskbar
  • Policy:Disable user tracking
    Description:Prevents the system from remembering the programs run, paths followed, and documents used.
    Registry Value: NoInstrumentation
  • Policy:Remove user name from Start Menu
    Description:Removes the user name from the Start menu.
    Registry Value: NoUserNameInStartMenu

其实还是有办法的:

http://bbs.wuyou.net/forum.php?mod=viewthread&tid=149282&page=2

仔细看了一下,那段VB代码的VISTA部分有点问题
索性我就全部翻译成VC吧

// For XP
void Pin()
{
CoInitialize(NULL);
CComPtr<IShellDispatch> pShell;
CoCreateInstance(CLSID_Shell, NULL, CLSCTX_SERVER, IID_IDispatch, (LPVOID*)&pShell);
CComPtr<Folder> pFolder;
pShell->NameSpace(CComVariant(_T(“C:\\Windows\\System32”)), &pFolder);
CComPtr<FolderItem> pItem;
pFolder->ParseName(CComBSTR(_T(“notepad.exe”)), &pItem);
pItem->InvokeVerb(CComVariant(_T(“附到「开始」菜单(&I)”)));
}
void UnPin()
{
CoInitialize(NULL);
CComPtr<IShellDispatch> pShell;
CoCreateInstance(CLSID_Shell, NULL, CLSCTX_SERVER, IID_IDispatch, (LPVOID*)&pShell);
CComPtr<Folder> pFolder;
pShell->NameSpace(CComVariant(_T(“C:\\Windows\\System32”)), &pFolder);
CComPtr<FolderItem> pItem;
pFolder->ParseName(CComBSTR(_T(“notepad.exe”)), &pItem);
pItem->InvokeVerb(CComVariant(_T(“从「开始」菜单脱离(&I)”)));
}

// For Vista,其实XP中也能用,就是比上面的多了个循环判断
void PinVista()
{
CoInitialize(NULL);
CComPtr<IShellDispatch> pShell;
CoCreateInstance(CLSID_Shell, NULL, CLSCTX_SERVER, IID_IDispatch, (LPVOID*)&pShell);
CComPtr<Folder> pFolder;
pShell->NameSpace(CComVariant(_T(“C:\\Windows\\System32”)), &pFolder);
CComPtr<FolderItem> pItem;
pFolder->ParseName(CComBSTR(_T(“notepad.exe”)), &pItem);
CComPtr<FolderItemVerbs> pItemVerbs;
pItem->Verbs(&pItemVerbs);
long lCount;
pItemVerbs->get_Count(&lCount);
for (long i=0; i!=lCount; i++)
{
CComPtr<FolderItemVerb> pItemVerb;
pItemVerbs->Item(CComVariant(i), &pItemVerb);
CComBSTR bstrName;
pItemVerb->get_Name(&bstrName);
if (bstrName == _T(“附到「开始」菜单(&I)”))
{
pItemVerb->DoIt();
}
}
}

这样整合进PECMD应该很容易啦^_^
CoInitialize(NULL);是COM的初始函数,程序的初始化部分写一次就可以了,我写的时候为了测试方便,所以每段函数里都有。
我用的XP测试,For Vista 的菜单名是用的XP的
用到几个ATL的工具类,纯API的话还得改改
PS: 没有缩进代码好丑^_^