I have already successfully created a context menu which allow users to process any type of files by my program, but when a user to select more than 1 file then click the context menu item, my program would be called and run for several times. How to make context menu to open multiple files in one process in C# Winform program? By the way the program has to be run as Administrator, and I have already set a manifest file for it.
Code:
try
{
RegistryKey _key = Registry.ClassesRoot.OpenSubKey("Folder\\Shell", true);
RegistryKey newkey = _key.CreateSubKey("MyProgram");
newkey.SetValue("Icon", Application.ExecutablePath);
RegistryKey subNewkey = newkey.CreateSubKey("Command");
subNewkey.SetValue("", Application.ExecutablePath + " \"%1\"");
subNewkey.Close();
newkey.Close();
_key.Close();
}
catch
{ }
try
{
RegistryKey _key = Registry.ClassesRoot.OpenSubKey("*\\Shell", true);
RegistryKey newkey = _key.CreateSubKey("MyProgram");
newkey.SetValue("Icon", Application.ExecutablePath);
RegistryKey subNewkey = newkey.CreateSubKey("Command");
subNewkey.SetValue("", Application.ExecutablePath + " \"%1\"");
subNewkey.Close();
newkey.Close();
_key.Close();
}
catch
{ }