How do you add an item to Explorer's ShellNew menu?
July 15, 2004 5:32 PM   Subscribe

I give up! Just how in the hell do you add an item to Explorer's ShellNew menu?

MSDN makes it sound easy:
To add a file-creation command to the New submenu, your application's files must have a file class associated with them. Include a ShellNew subkey under the file extension key. When the File menu's New command is selected, the Shell will add it to the New submenu. The command's display string will be the descriptive string that is assigned to the program's ProgID.

Assign one or more data values to the ShellNew subkey to specify the file creation method. The available values follow. [...]
So here's what I have: a file extension ".build" under HKEY_CLASSES_ROOT, with a ProgID of "NAnt.Buildfile." There's a "ShellNew" key under that with a "NullFile" value attached. (I want to use a template or possibly write a wizard, but I'll settle for getting the simplest case working first!) I've set up a corresponding "NAnt.Buildfile" key to give the file class a friendly name, a default icon, and a couple of verbs (Edit and Build). According to MSDN, this is more than the minimum required, but no new entry appears in the ShellNew menu; however, ".build" files appear with the icon I selected and fully-functional Edit and Build verbs. Figuring this is Windows and nothing is as easy as a couple registry entries, I've searched for some sort of API call I need to make to get Explorer to recognize the ShellNew entry but I've come up empty. Help!
posted by kjh to Computers & Internet (6 answers total)
Find your current ShellNew folder (mine is C:\WINNT\ShellNew) and within it place a file named that contains whatever content you want a .build file to contain by default.

Go back into regedit. Under .build, create a new key called ShellNew. Under ShellNew, create a new string value called FileName whose value is the name of the file you created above. Close regedit and check the ShellNew menu.
posted by Danelope at 6:03 PM on July 15, 2004

Still nada.
posted by kjh at 6:38 PM on July 15, 2004

Did you wait a bit and/or try rebooting after following the above advice? Windows has a tendency to cache file association data until it's forced to update. You might try installing TweakUI, going to the Repair tab, and rebuilding icons to flush the cache.

Barring that, delete your .build and NAnt.Buildfile keys and their contents from the registry, dump the following into a .reg file, and double-click to add:

Windows Registry Editor Version 5.00



@="Build File"




@="\"notepad.exe\" \"%1\""

Provided the file is still in your ShellNew directory, and your file association cache is refreshed afterward, this should work well enough for you to build up. It works for me, at least.
posted by Danelope at 7:23 PM on July 15, 2004

Finally! That did it, though for the life of me I can't tell how it's different from what I had. Thanks, Danelope!
posted by kjh at 7:59 PM on July 15, 2004

If I understand correctly, can't the same thing be achieved a lot easier by dropping a file into TweakUI's Templates list? That's how I usually add items to the New menu.
posted by milov at 12:10 AM on July 16, 2004

Oops, I see you mention trying an API call so I guess this is something you're trying to do automatically in a program you're writing.
posted by milov at 3:09 AM on July 16, 2004

« Older Flash! Aaaah-ahhh!   |   Advanced Excel tutorial suggestions Newer »
This thread is closed to new comments.