Creating a general (*) context menu shell item?

J

JShrager

I want to create my own shell-based shortcut menu item that comes up on
any file. This MSDN document:


http://msdn.microsoft.com/library/d...l_basics/shell_basics_extending/extending.asp

explains how to do this for a given file type. I've tried this and it
works, so I know that my .exe is right, and that I can hack this
correctly for a given (made up) file type (.foo)

This document:

http://windowssdk.msdn.microsoft.com/en-us/library/ms649567.aspx#registering

Explains how to create a general context handler, and how to hook it
into the context menu under the * (all types) type in
HKEY_CLASSES_ROOT.

BUT...

I can't find anything that tells you how to hook one's own shell-type
(.exe-type) context handler under * (all types), and I haven't been
able to figure it out by example (because all the default ones are
registered types!)

For example, the 1st doc above tells you to change the Default entry
for .foo in hkey_classes_root to the name of my special handler. And
that works... for a specific file type (.foo), but I obviously do NOT
want to change the Default key value for the * type!

So, how can I add a shell-type context menu hander for * (all types)?

Thanks in advance!
 
R

Ramesh, MS-MVP

Here is an example:

- - -
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with Notepad\command]
@="Notepad.exe %1"

- - -

This REG file adds "Open with Notepad" static context menu for all file
types.

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows XP Shell/User]
Windows® XP Troubleshooting http://www.winhelponline.com


I want to create my own shell-based shortcut menu item that comes up on
any file. This MSDN document:


http://msdn.microsoft.com/library/d...l_basics/shell_basics_extending/extending.asp

explains how to do this for a given file type. I've tried this and it
works, so I know that my .exe is right, and that I can hack this
correctly for a given (made up) file type (.foo)

This document:

http://windowssdk.msdn.microsoft.com/en-us/library/ms649567.aspx#registering

Explains how to create a general context handler, and how to hook it
into the context menu under the * (all types) type in
HKEY_CLASSES_ROOT.

BUT...

I can't find anything that tells you how to hook one's own shell-type
(.exe-type) context handler under * (all types), and I haven't been
able to figure it out by example (because all the default ones are
registered types!)

For example, the 1st doc above tells you to change the Default entry
for .foo in hkey_classes_root to the name of my special handler. And
that works... for a specific file type (.foo), but I obviously do NOT
want to change the Default key value for the * type!

So, how can I add a shell-type context menu hander for * (all types)?

Thanks in advance!
 
N

NewScience

I've done this before ... after a while it's pretty easy.

When you write you Context Menu handler, you request from the system a
unique CLSID. There is a freeware progam from MS that will provide this.
Search for CLSID generator.

Then when you add the Contenxt Menu handler to
'*'/shellex/ContextMenuHandlers, you add a unique name where it's default
value is that unique CLSID.

You must provide DLLRegister handler in your code as well as DLLUnregister
handler. This add/remove the entry from the registry.

Then each time a file is right-clicked, all '*' ContextMenuHandlers are
queried, passing a Yes/No back to the caller, and if Yes, the menu item name
is added to the list. Then the extension is checked for a
shellex/ContextMenuHandlers items, and handled the same way as '*'
ContextMenuHandlers items.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top