[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

adding a right click entry in explorer

Posted on 2000-02-03
14
Medium Priority
?
226 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:ocsscott
  • 8
  • 5
14 Comments
 
LVL 6

Expert Comment

by:st_steve
ID: 2489138
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....



0
 

Author Comment

by:ocsscott
ID: 2489565
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
0
 

Author Comment

by:ocsscott
ID: 2490898
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 6

Expert Comment

by:st_steve
ID: 2492281
"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....
0
 

Author Comment

by:ocsscott
ID: 2492975
no problem, thanks alot and once you get back to me all them points are yours ;)
0
 
LVL 6

Expert Comment

by:st_steve
ID: 2493881
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...
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2493920
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!
0
 
LVL 6

Expert Comment

by:st_steve
ID: 2493929
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)

0
 
LVL 6

Expert Comment

by:st_steve
ID: 2493931
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..
0
 

Author Comment

by:ocsscott
ID: 2494264
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.
0
 
LVL 6

Expert Comment

by:st_steve
ID: 2494293
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...
0
 
LVL 6

Accepted Solution

by:
st_steve earned 400 total points
ID: 2494308
ok...try this..

add the following to registry

HKEY_CLASSES_ROOT\*\shellex\ContectMenuHandlers\(YourprogramName)

change the default string to a "unique" class ID (don't ask me how to do this..usually...it 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)

HKEY_CLASSES_ROOT\Directory\shellex\ContectMenuHandlers\(YourprogramName)

HKEY_CLASSES_ROOT\Directory\shellex\DragDropHandlers\(YourprogramName)

HKEY_CLASSES_ROOT\Folder\shellex\ContectMenuHandlers\(YourprogramName)

HKEY_CLASSES_ROOT\Folder\shellex\DragDropHandlers\(YourprogramName)

HKEY_CLASSES_ROOT\(YourprogramName)\shell\open\command
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...





0
 

Author Comment

by:ocsscott
ID: 2501189
thansk alot
0
 
LVL 6

Expert Comment

by:st_steve
ID: 2501907
hey...no probs....glad I could help...and thanks for the points :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question