Windows Explorer: How to create additional button?

2019-06-10 11:33发布

Explorer of Windows 7 uses a new light-blue bar with buttons like "Organize", "Share", "New Folder" etc.

How can I create a new button ? Do I need to create a plugin for explorer.exe, and if, how do I do it (using Visual Studio .NET) ?

Or is it a simple registry key I have to set which points to an exe or bat?

Thanks in advance and best regards

1条回答
Rolldiameter
2楼-- · 2019-06-10 12:28

It's a registry key, but not quite so simple. You have to do several steps to add one button.

You may have noticed that the Win7 Explorer adjusts its toolbar to match the content that is being displayed. For example the buttons shown for the control panel folders are different than the ones for documents or the music library folder. You can find a large list of different folder types under the registry key

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes

Click on each UID shown there to find out what folder type it is for. For example here you see the entry for folders in the generic library type: generic library type, registry keys

So the first thing you have to do is to find the folder type for which you want to add your own button.

Once you found the right UID, you might have to take ownership of those keys. Otherwise you won't be able to modify them: Right-click on that key and choose Permisssions...

  1. Click the Advanced button.
  2. Click the Owner tab.
  3. Under Change Owner to: select Administrators.
    Click Apply and verify that "Current Owner" is set to Administrators. Click OK to save the change.
  4. Back in the Permissions dialog, click Administrators and then click (to check it) Full Control
  5. Click OK to save the settings and close the dialog box.

The next step is to create the keys and values necessary for your own button:

  • Add a new key, TasksItemsSelected
  • Add a new key, TasksItemsSelected\0
  • Create a new GUID (use guidgen.exe) for your command.
  • add the key TasksItemsSelected\0\<yourguid>, then add the strings Title and InfoTip and give them the appropriate values. You can also set an icon here, using the string Icon with the value pointing to an icon file.
  • Add the keys TasksItemsSelected\0\<yourguid>\shell\InvokeTask\command
  • as default value of the command key, enter the command you want to execute.

Now your registry entry should look something like this: title and infotip command

When the command runs, it will receive at least two parameter values.

  %1 -- The path of the folder that was being displayed
  %2 -- The pathname of the file that was selected.

If you select more than one file before clicking the mycommand button, then the subsequent filenames will be in subsequent parameters.

And last but not least: if you want to add your own button for situations where nothing is selected, do everything as mentioned above, but use the registry key TasksNoItemsSelected instead of TasksItemsSelected

查看更多
登录 后发表回答