Platform SDK: Active Directory, ADSI, and Directory Services

Registering a Context Menu Item that Starts an Application in a Display Specifier

If the context menu item starts a program, the value is a string with the following format:

ordernumber,menuitemtext,command

In this example, the ordernumber is a signed number that represents the menu item's position on the context menu. When a context menu is first displayed, the values are sorted using a signed comparison of each value's ordernumber. If more than one value has the same ordernumber, those context menu items are loaded in the order they are read from the directory; however, you should use a non-existing ordernumber (that is, one that has not been used by other values in the property). There is no prescribed starting position and gaps are allowed in the ordernumber sequence.

The menuitemtext is the text used to display this context menu item on the context menu. The menuitemtext cannot contain commas. The menuitemtext can contain an ampersand (&) to set the shortcut key for the menu item. For example, the following value makes d the shortcut key:

1,&Do this,do.exe 

The command is the program that will be executed by the snap-in. Either the full path must be specified or the application must be in the computer's path environment variable. The program is invoked using the ShellExecute function. The command cannot contain additional parameters (for example, Notepad myfile.txt). Since ShellExecute is used, documents can be specified as the command (for example the command d:\myfile.doc will open d:\myfile.doc based on the program associated with the .doc extension). Paths and application names with spaces are allowed. Note that the selected object's distinguished name and class are passed as the first and second arguments, respectively, of the program invoked by command.

In the Windows shell, multi-selection is supported. The command is invoked for each selected object. In Active Directory administrative snap-ins, multi-selection is not supported, that is, the command is not invoked at all. Only single selection is supported.

Important  For the Windows shell, display specifier information is retrieved at user logon and cached for the user's session. For the administrative snap-ins, the display specifier information is retrieved when the snap-in is loaded and is cached for the lifetime of the process. For the Windows shell, this means changes to display specifiers take effect after a user logs off and back on again. For the administrative snap-ins, changes take effect when the snap-in or console file is reloaded (that is, if you start a new instance of the console file or new MMC.EXE instance and add the snap-in, the latest display specifier information will be retrieved).