Link to home
Start Free TrialLog in
Avatar of ocsscott
ocsscott

asked on

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.
Avatar of st_steve
st_steve

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



Avatar of ocsscott

ASKER

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
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
"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....
no problem, thanks alot and once you get back to me all them points are yours ;)
ok..here it is...

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

----------
REGEDIT4
[HKEY_CLASSES_ROOT\Directory\shell\opennew]
@="Open New &Window"
[HKEY_CLASSES_ROOT\Directory\shell\opennew\command]
@="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
http://support.microsoft.com/support/kb/articles/Q145/6/79.asp?LNG=ENG&SA=MSDN 
 

Cheers!
you can also call the above .reg file from your VB application, using ShellExecute API....here'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..
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.
oh...so 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...
ASKER CERTIFIED SOLUTION
Avatar of st_steve
st_steve

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thansk alot
hey...no probs....glad I could help...and thanks for the points :)