adding a right click entry in explorer

how can I add a new entry in the right click menu of explorer.  for example most zip or virus product add a menu item too allow you to zip or scan a file or folder.  What I would like to do is add an entry to allow my program run from a right click and process the file or folder I have selected in explorer.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you need to add som keys and values in the registry.....for example...if you want to add an entry to the right-click menu when you click on the "start" button... do the following..

Open regedit and find an entry in HKEY_CLASSES_ROOT that says "Directory"

it has all the entries you can find when you right-click on the start button (except "open" and "Explore"..they're already there by default and are internal to Windows)

there should be a subkey: "shell"...

create another subkey in this "shell" subkey...and name it whatever you want. on the right pane, change the caption (or default string) to whatever you want it to appear on the right-click menu.

next create another subkey in the key you just created. call this latest subkey "command"..and change the value of "default" string to point to the application path.

now..all this....just to get it on the start menu right-click menu....

ocsscottAuthor Commented:
very cool ill try it.. do you know how the directory is passed to the program.. for example if in explorer I right click on a folder name I want to path sent to my program    any ideas?   thanks scott
ocsscottAuthor Commented:
actually the folder thing works great what if I want the right click to work on a file  my option only shows on folders  I assume I do the same thing but to a key other than directory..any idea which key that would be??  thanks
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

"ocsscott"...give me some time..I did  this a long time ago..(about 6 months ago)..and I kind of forgot how to do it....
ocsscottAuthor Commented:
no problem, thanks alot and once you get back to me all them points are yours ;)
st_steveCommented: it is...

Open your notepad and copy this, save the file with extension .reg

@="Open New &Window"
@="explorer %1"

when you deuble-click on the file, you 'll have a new entry when you right-click on an object. the entry would read "Open new window" and it'll launch it using explorer.

So you can replace the caption to anything you want, and change the container application to your application: eg: change "@="Open New Window" to "@="Ocsscott's program" and change "@=explorer %1" to "@=ocsscott.exe %1"..

got it?? hope this is what you wanted...
You may want to read and write the registry entries with your program instead of executing a reg file...

Check out this microsoft link:

HOWTO: Use the Registry API to Save and Retrieve Setting 

you can also call the above .reg file from your VB application, using ShellExecute's the code for doing that...

'put this in a module
Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As _
String, ByVal lpFile As String, ByVal lpParameters As String, ByVal _
lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Const SW_SHOWNORMAL = 1

now call this routine when you want to add the entries to your registry from your application:

dim lReturn as Long
lReturn = ShellExecute(hwnd, "open", "registry_filename.reg", vbNull, vbNull, 1)

if you want to add the entries manually, I have a registry editing, deleting and adding routine....msg me ...I can send you the module via email..
ocsscottAuthor Commented:
steve this works great for folders but doesn't wotk if I rt click on just a file.  are you sure i still us the directory subkey?.   I added them but the entry only shows if I point to a folder not when i click on a file.
st_steveCommented: you want something like WinZip?? let me dig my brain out for a while, ok? so far ...this is the only way I can remember...just the directory...not to a file...let me think...
ok...try this..

add the following to registry


change the default string to a "unique" class ID (don't ask me how to do only need to be unique....

create HKEY_CLASS_ROOT\CLSID\(unique classID you nominated)

change default string to (YourprogramName)

'add these if you want these functionalities..(pretty self-explanatory)





change the default string value to point to your program (full path) and add "%1" at the end (the parameter)

I think that should do the trick...try it...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ocsscottAuthor Commented:
thansk alot
st_steveCommented: probs....glad I could help...and thanks for the points :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.