How to add item to windows explorer content menu in delphi?
Asked Answered
B

3

6

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.

Baudelaire answered 26/9, 2010 at 12:43 Comment(0)
S
8

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+.

Sociopath answered 26/9, 2010 at 14:11 Comment(2)
+1 for suggesting Shell Extension but please do note that since we cannot create x64 DLL's (yet) in Delphi it will only work for x86 explorer and x86 apps that support Shell Extensions (on both x86 and x64 windows).Pauperize
The delphi3000 link is gone, and it's not in the wayback machine, anyone can share the code that uses the registry? I'm looking into register arbitrary (*) file class but couldn't find a way to do it (MS is no that clear to me :()Putout
G
3

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

Glint answered 26/9, 2010 at 16:17 Comment(2)
Rob, 11 years later and I am interested in this subject. I would like to code a Content Menu editor, I cannot find an app to remove invid COntenxt Menu items, so I may as well code it, and throw in a few more features. BUT, in a first search, all solutions, including yours, suggest ActiveX, Any idea how to approach it without ActiveX? And eany reading links in general on the (Windows Explorer) Context Menu?Swanhildas
There are two kinds of context-menu items. In one, you just provide the text that should display, and the command line that Explorer should run when the user chooses the menu item. In the other, you specify a DLL that Explorer will load that will provide one or more menu items. ActiveX is just COM, and COM is essentially the Windows plug-in system. You can't write the latter style of context-menu item without COM. But you don't need that. You just need to clear out the obsolete registry entries left behind by programs you've uninstalled.Glint
B
1

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.

Bespoke answered 26/9, 2010 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.