Gmadlobt Gadasarevad
Gmadlobt Gadasarevad

Reputation: 13

Add Custom Tool to Windows Command Bar With Dynamic Verb

How can I create a Windows Explorer command bar tool that takes a dynamic string?

I already know how to add my tool to the command bar and execute the command on click.

enter image description here

But I need a toolbar like the second one after Organize.

I need that when I click to the file name of my tool be like My Tool - File name (selected.txt) or My Tool - Selected File Extension (.txt).

Does anyone have an idea about how to do that?

Upvotes: 1

Views: 831

Answers (1)

Denis Anisimov
Denis Anisimov

Reputation: 3317

1) Create a shell extension. Your shell extension must implement IInitializeCommand, IObjectWithSite, IObjectWithSelection, IExplorerCommand and IExplorerCommandState.

2) Register your shell extension:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\YourCommandID]
@=YourTopCommandCaption
ExplorerCommandHandler=YourCLSID

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{5c4f28b5-f869-4e84-8e60-f11db97c5cc7}\TasksItemsSelected]
@=YourCommandID

If default value of TasksItemsSelected key is not empty you MUST add new string to old! For example prev value is Windows.copy the new must be Windows.copy;YourCommandID

{5c4f28b5-f869-4e84-8e60-f11db97c5cc7} is FOLDERTYPEID_Generic.

3) IExplorerCommand.GetFlags must return ECF_HASSUBCOMMANDS or ECF_ISDROPDOWN

4) IExplorerCommand.EnumSubCommands must return object implements IEnumExplorerCommand

5) IEnumExplorerCommand.Next must return object implements IExplorerCommand, IObjectWithSite and IObjectWithSelection. Every object is a single command of sub menu.

It works only on Win7.

Upvotes: 3

Related Questions