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\"");
}