Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add item to windows explorer content menu in delphi?

I would like to create menu item in windows explorer content menu (for all file types) which after click will open my application and pass the selected file name to it. Is there any tutorial for this ? I know there is ShellPlus component available but it's a bit outdated.

like image 204
chubbyk Avatar asked Sep 26 '10 12:09

chubbyk


People also ask

How do I add to Explorer context menu?

You can add favorites to your QAP menu with the Windows Explorer context menus. Right-click or Shift+Right-click on any file or folder to show its context menu. QAP's command in this menu are recognizable by the QAP icon on the left. You can also right-click the Desktop background to show the QAP popup menu!

What is the context menu in File Explorer?

A context menu is a pop-up menu that provides shortcuts for actions the software developer anticipates the user might want to take. In a Windows environment, the context menu is accessed with a right mouse click.


3 Answers

Registry

This method is easy since it comes down to adding some registry keys. The downside is that you can't put any logic in it. You can read about it here and here a simple example in Delphi. You get a bit more control if you are using DDE to execute the menu items. See here for a Delphi example.

Shell Extension

This method is a bit more work, but you can completely control the context menu from code. You would have to write a DLL, implement IContextMenu (or others) and register the dll with Windows Explorer. You can read about it here. You already mentioned Shell+.

like image 99
Lars Truijens Avatar answered Oct 26 '22 23:10

Lars Truijens


Delphi includes a demo project for shell extensions. Look in the Demos\ActiveX\ShellExt folder.

like image 24
Rob Kennedy Avatar answered Oct 26 '22 22:10

Rob Kennedy


This is possible independendly from the programming language by setting up shortcut menu handlers for the desired filetype(s) in the registry. There you can call your application with the correct path, the correct options and the right file-placeholders.

See the MSDN article on Creating Shortcut Menu Handlers for more detailled information.

like image 25
Kosi2801 Avatar answered Oct 27 '22 00:10

Kosi2801