Friday, November 23, 2018

Putting items in the New context menu above the separator line

One user wanted to put a custom New submenu entry above the separator line (right under Folder and Shortcut) instead of among the normal entries. At first I assumed this was impossible and that the above-separator entries were hardcoded, but then I did some disassembling.

shell32.dll has a CNewMenu::_BeforeSeparator function that determines whether a given entry will be placed above the separator. It first checks the file type against a hardcoded list, but if that check fails, it also checks a flag in the NEWOBJECTINFO structure. It looks like those structures are set up by the _GetNewObjectInfoForKey structure, which calls _GetConfigFlags on the Config subkey of ShellNew to populate the field containing that flag. _GetConfigFlags checks for the existence of a bunch of entries, setting flags as it goes along. The Registry entry for the flag of interest is named BeforeSeparator.

So, placing a value named BeforeSeparator in the Config subkey under ShellNew for a New menu item will move that menu entry above the separator:


No comments:

Post a Comment