开发者

Windows Explorer: How to create additional button?

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 开发者_JAVA技巧registry key I have to set which points to an exe or bat?

Thanks in advance and best regards


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:

Windows Explorer: How to create additional button?

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:

Windows Explorer: How to create additional button?

Windows Explorer: How to create additional button?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜