Does anybody know how I can associate a menu-item with my program when the user for example right clicks on their desktop? Or for example, let's say the user selects a series of files and/or folders and right clicks. How can I create a menu-item in the list of the items that will popup in the default menu?

Thanks in advance
Posted on 2008-02-25 00:07:52 by XCHG
I'm having problems with my website provider this weekend but I have attached an example here...

Posted on 2008-02-25 00:50:21 by donkey
Hi Edgar-

That works if you click on a file, do you have anything that works if you right click on the naked desktop?

Posted on 2008-02-25 08:15:29 by JimG
JimG, in DllRegisterServer function, add your CLSID to \SOFTWARE\Classes\Directory\Background\shellex\ContextMenuHandlers.
Posted on 2008-02-25 10:35:42 by sapero
Thanks sapero, I'll give it a try.
Posted on 2008-02-25 11:48:05 by JimG
Okay here's the deal! The context menu handler can handle specific file types. Right? But let's say the user selects a bunch of files with different extensions and a couple of folders and then right clicks. How can I handle that? I have looked in many places but all of the codes just deal with specific file types. For example, UltraEdit (Hex Editor) appears in the Explorer's context menu wherever you right click on any file or a group of files/folders. That's what I have to create and have no idea how to by the way.
Posted on 2008-02-26 10:44:30 by XCHG

Multiple files are handled through IContextMenu::InvokeCommand, you can use DragQueryFiles to extract the information for more than one file, in my example I do not loop the query but it is not difficult to add the couple of extra lines needed.
Posted on 2008-02-26 10:52:33 by donkey
Are you talking about multiple files of the same type? I am not if you are :(
Posted on 2008-02-26 11:01:23 by XCHG

You can specify any file type by using the "HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers" file class when registering the menu handler, then all files will be passed to it.
Posted on 2008-02-26 11:18:44 by donkey
Hits the nail on the head! Thanks.
Posted on 2008-02-26 12:38:27 by XCHG

Hits the nail on the head! Thanks.

No probs. Good luck with the project.
Posted on 2008-02-26 15:13:45 by donkey

Hits the nail on the head! Thanks.

No probs. Good luck with the project.

Thank you so much. I did finish the project. It was a code that I had to write for somebody in and I did it in Delphi which helps a lot for such projects. However, I have to mention that to register the Shell Extension to work with both files and folders, I had to write the Registry entries for both HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers and HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers. Before that, when a list of files and folders was selected, you couldn't see the Shell context menu item. But after registering the context menu handler for both * and Directory, it worked fine.

Thank you again for your help. Your example helped a lot.
Posted on 2008-03-02 06:15:18 by XCHG