Help - Search - Members - Calendar
Full Version: Creating a Context Menu Entry
BleepingComputer.com > Software > Programming
   
Amazing Andrew
So, I've written a nifty little app that does a cool thing using magic and Lucky Charms. Trouble is it's fairly useless unless I can cause it to be invoked from Explorer's context menu.

All I need to know is how to create a handler, in the registry preferably, that only shows up when a file is right-clicked (not a folder) and launches my program with the file's path as an argument.

Any help is appreciated.
groovicus
I know how to add an option ot the context menu, but I don't know how to make it aware of the file type in order to determine whether or not it should be visible; I have a hunch that one would have to alter the right-click handler. I saw this a while back that looks promising that may give you an idea of how to do it, but I have never messed with it.
Billy O'Neal
Does it need to operate on any file or only certain types you're looking for?

What language is the app written in?

Billy3
Amazing Andrew
It needs to operate on any and all files of all types, but not directories. The app is written in RealBasic, which is similar in most respects to VB.

I'll take a look at FileMenu Tools. If need be, I'll create the handler with it and reverse engineer what it did to do it tongue.gif Thanks guys!
Romeo29
These are the manual steps. You can convert them into a function :

Lets assume your program is installed in path C:\Magic\Magic.exe

1. Create a subkey under HKCR\*\shell of any name you like. Lets say Magic, so final subkey you create would be HKCR\*\shell\Magic
2. Set the default value under this subkey to any name you want to appear in right-click context-menu say, Do Magic
3. Create a subkey command under the newly created key in step 1.
4. Set default value under this command key to path name of exe followed by %1. In this case "C:\Magic\Magic.exe" %1. The inverted commas are necessary only if path contains space.

You will immediately see the changes in context menu, no restart etc. is necessary. This way of handling context menu is used when you have to pass parameters directly to EXE. The newer extended way with GUID's is used when you have a special DLL to handle context menu.

EDIT: If you want to add context menu only to a particular type file just replace HKCR\* with extension of that type. For example, for text files (.txt), follow the process under the key HKCR\.txt\. The HKCR\* is for all types of files.
groovicus
That's cool! Can a person use regex expressions to limit the particular files, or can one just include an array of files one wants associated with the key?
Amazing Andrew
Exactly what I was looking for! Thanks!
Amazing Andrew
Everything works perfectly now.
Romeo29
QUOTE(groovicus @ Oct 11 2009, 09:50 PM) *
That's cool! Can a person use regex expressions to limit the particular files, or can one just include an array of files one wants associated with the key?

In my opinion, regex is not allowed, you have to repeat process for each type of file you want.

QUOTE(Amazing Andrew @ Oct 12 2009, 01:35 AM) *


Nifty app smile.gif

Billy O'Neal
I'll have to take a look. :grin: This is the one I use, but it doesn't do virus total.

Billy3
Amazing Andrew
QUOTE(Romeo29 @ Oct 12 2009, 09:34 AM) *
Nifty app smile.gif

QUOTE(Billy O @ Oct 12 2009, 09:44 AM) *
I'll have to take a look. :grin: This is the one I use, but it doesn't do virus total.

Thanks!

I had been using MD5 Context Menu (still do, actually) but it was a pain to have to Copypasta each checksum manually.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.