Registering Commands

Many of the commands found on icons, including Send To, Cut, Copy, Paste, Create Shortcut, Delete, Rename, and Properties, are provided by their container — that is, their containing folder or the desktop. But you must provide support for the icon's primary commands, also referred to as verbs, such as Open, Edit, Play, and Print. You can also register additional commands that apply to your file types, such as a What's This? command and even commands for other file types.

To add these commands, in the HKEY_CLASSES_ROOT key, you register a shell subkey and a subkey for each verb, and a command subkey for each menu command name.

HKEY_CLASSES_ROOT
ApplicationIdentifier = Type Name
shell [ = default verb [,verb2 [,..]]
verb [ = Menu Command Name]
command = pathname [parameters]

You can also register a DDE command string for a DDE command.

HKEY_CLASSES_ROOT
ApplicationIdentifier = Type Name
shell [ = default verb [,verb2 [,..]]
verb [ = Menu Command Name]
ddeexec = DDE command string
Application = DDE Application Name
Topic = DDE topic name

A verb is a language-independent name of the command. Applications may use it to invoke a specific command programmatically. The system defines Open, Print, Find, and Explore as standard verbs and automatically provides menu command names and appropriate access key assignments, localized in each international version of Windows. When you supply verbs other than these, provide menu command names localized for the specific version of Windows on which the application is installed. To assign a menu command name for a verb, make it the default value of the verb subkey.

The menu command names corresponding to the verbs for a file type are displayed to the user, either on a folder's File drop-down menu or pop-up menu for a file's icon. These appear at the top of the menu. You define the order of the menu commands by ordering the verbs in the value of the shell key. The first verb becomes the default command in the menu.

By default, capitalization follows how you enter format the menu command name value of the verb subkey. Although the system automatically capitalizes the standard commands (Open, Print, Explore, and Find), you can use the value of the menu command name to format the capitalization differently. Similarly, you use the menu command name value to set the access key for the menu command following normal menu conventions, prefixing the character in the name with an ampersand (&). Otherwise, the system sets the first letter of the command as the access key for that command.

To support user execution of a verb, provide the path for the application or a DDE command string. You can include command-line switches. For paths, include a %1 parameter. This parameter is an operational placeholder for whatever file the user selects.

For example, to register an Analyze command for an application that manages stock market information, the registry entries might look like the following.

HKEY_CLASSES_ROOT
stockfile = Stock Data
shell = analyze
analyze = &Analyze
command = C:\Program Files\Stock Analysis\Stock.exe /A

You may have different values for each command. You may assign one application to carry out the Open command and another to carry out the Print command, or use the same application for all commands.