- NSIS Discussion
- Shell extension on folders
Archive: Shell extension on folders
Wurstteppich
9th February 2006 20:02 UTC
Shell extension on folders
Hello
i need to register a command in the shell - right click menu - which sends the path of to a directory to a program. That means i want to have a menu item when i right click on a directory in the explorer which says something like "Add this folder to <MyProgramNameHere>" which then starts my program like this:
MyProgram.exe C:\ExampleDir\ExampleDir
Is that possible in any way ?
I would be glad to hear some ideas from you guys :)
Thanks in advance!
goldy1064
9th February 2006 22:06 UTC
Add a new key to HKEY_CLASSES_ROOT\Directory with your program name. Set the default value to the text to display in the right-click menu. Now add a subkey called command. Make the default value the path to your application in this form: "C:\My Program\myprogram.exe" "%1".
Wurstteppich
9th February 2006 23:22 UTC
Ah thanks, i assumed something like the last part you described, but didn't exactly know where to set it with a directory. I just knew it for extensions.
Thanks !
goldy1064
10th February 2006 00:38 UTC
Actually, I was browsing a little more and came across this MSDN article. It looks like it would be better placed in HKEY_LOCAL_MACHINE\SOFTWARE\Classes or in HKEY_CURRENT_USER\SOFTWARE\Classes, since that is where HKEY_CLASSES_ROOT is made up from.
RobGrant
10th February 2006 08:51 UTC
Hmm, while I don't need to do this, I don't really understand what you're saying. My Registry entries there don't correspond exactly to what you're saying (i.e. in Directory there isn't just a list of keys with display names and program executable subkeys. It looks like this:
HKEY_LOCAL_MACHINE
`->SOFTWARE
`->Classes
`->Directory
|+]Background
|->DefaultIcon
|+]shell
`+]shellex
Now, shellex contains some useful stuff, mostly classids associated with program names. However I'm a bit confused as this is quite different to what you said.
Thoughts? :) I'm just curious, I don't need this functionality.
Wurstteppich
2nd March 2006 14:17 UTC
Me neither. The existing structure within that key doesn't imply that the custom key is set in the "Directory" key itself.
The other programs registered there (zip program, icq,...) however seem to use a custom class id which have a dll which they use to display their shell extensions. Can shell enhancements on directories not be used to hand over the full path to just a simple executable ? If not how can i solve this (how to create a dll to have context menu on directories with your own entries?) ?
dienjd
2nd March 2006 16:03 UTC
Is this what you want? It copies the path to the clipboard. Then you could use this function to retrieve it (or modify the DLL to send the path directly to the program you want it to).
Wurstteppich
3rd March 2006 23:32 UTC
This looks like a start for my purpose, but unfortunatly i dont know C++ programming (we a little but not enough). Do you have an other example where the program is started with Program.exe %1 after clicking on "Copy Folder Location" ?
Thanks for you answer!
OldGrumpy
4th March 2006 07:46 UTC
What about creating a link in the SendTo folder? If your menu entry has to be directly in the context menu, you will probably have to create a custom dll. With the SendTo menu entry, all you have to do is to create a shortcut file in the SendTo folder somewhere under Documents and Settings\Username\... - at the expense of an extra mouse move or click ;)
Wurstteppich
4th March 2006 16:27 UTC
That would be a possible solution and surely not too bad, but i would like to try it with a dll in the first place. It would be more nice to have it in the main menu. I know it is a small issue and something cosmetical, but it would just be more pleasant to have it there.
But thanks for that suggestion!
So does anyone else know where i can such an example dll source which i can modify to my needs without any bigger knowledge of programming ?
wilsonronl
25th September 2006 22:43 UTC
Try setting the default key to HKEY_CLASSES_ROOT\Directory\shell\progname\command
to something like:
"c:\path\to\program.exe" "%1"