Adding to drop down menu on right click

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi

How to add a custom functionality to the pop menu when a user right clicks on a file
i.e when you right click on media file add-to-playlist command will appear for windows media player

Thank
manoj
 
First you have to associate an extension with a type of file. This is stored
under
HKEY_CLASSES_ROOT\[.ext]

Then put actions under that type of file, stored under:
HKEY_CLASSES_ROOT\[FileType]

Here is some code from one of my projects that adds an extension ".c2c", a
file type "CopyToConfig.Project" and behavior. This should cut it.

- Noah Coad -
Microsoft MVP

public static void ConfirmRegEntries()
{
RegistryKey rkey = Microsoft.Win32.Registry.ClassesRoot;
rkey.CreateSubKey(".c2c").SetValue("", "CopyToConfig.Project");
rkey = rkey.CreateSubKey("CopyToConfig.Project");
rkey.SetValue("", "CopyTo Configuration Project");
rkey.CreateSubKey("DefaultIcon").SetValue("", Application.ExecutablePath +
",0");
rkey = rkey.CreateSubKey("shell");

RegistryKey keycmd = rkey.CreateSubKey("Open");
keycmd.SetValue("", "&Open");
keycmd.CreateSubKey("Command").SetValue("", "\"" +
Application.ExecutablePath + "\" /open \"%1\"");

keycmd = rkey.CreateSubKey("ExecuteLocal");
keycmd.SetValue("", "Execute &Local");
keycmd.CreateSubKey("Command").SetValue("", "\"" +
Application.ExecutablePath + "\" /execlocal \"%1\"");

keycmd = rkey.CreateSubKey("ExecuteRemote");
keycmd.SetValue("", "Execute &Remote");
keycmd.CreateSubKey("Command").SetValue("", "\"" +
Application.ExecutablePath + "\" /execremote \"%1\"");
}
 
Back
Top