>I have a need to edit the registry to add an item to a context menu. Do you
have any sample code on how to add this to the registry and then execute
an
application when the item is clicked? Thanks for any reply.
Well I don't really have any sample code but to do it manually I do this:
1) In HKEY_CLASSES_ROOT find the extension you require to add a context menu
item for. In my case it was ".dll". In this key find the value for the
default item. In my case it was "dllfile".
2) Still in HKEY_Classes_ROOT find a key for the value you have just looked
up ("dllfile").
3) Under this key add another key called "Shell".
4) Under this key add another with the name that you wish to appear ont he
context menu. In my case I want to open an app that will register the DLL so
I called it register.
5) Under this key add a key called "command"
6) Set the value of the default item for the "command" key to the path to
the executable you wish to run. Remember to encase it in quotes if there are
going to be any spaces and you may follow it with a "%1" (include the quotes
here too) to pass the selected file to the executable on the command line.
Obviously this would be easy to write in code.
So for my example, an export of this part of the registry looks like this:
-------------
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\dllfile\Shell\Register\Command]
@="\"D:\\Projects\\Visual Studio Projects\\MyExecutable.exe\" \"%1\""
-------------
You can also pass other stuff in other than the file name of the file but
you'll have to look this up on MSDN.
Hope that helps..... does anyone have any ideas on my original question?