Taking multiple files (arguments) from the context menu of a Windows shell in C #

I am writing a C # application and it takes files as an argument, I added it to the shell context menu with the code shown below;

if (((CheckBox)sender).CheckState == CheckState.Checked) { RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes\\*\\shell\\" + KEY_NAME + "\\command"); if (key == null) { key = Registry.CurrentUser.CreateSubKey("Software\\Classes\\*\\shell\\" + KEY_NAME + "\\command"); key.SetValue("", Application.ExecutablePath + " \"%1\""); } } else if (((CheckBox)sender).CheckState == CheckState.Unchecked) { RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes\\*\\shell\\" + KEY_NAME); if (key != null) { Registry.CurrentUser.DeleteSubKeyTree("Software\\Classes\\*\\shell\\" + KEY_NAME); } 

It works well, but if I select multiple files, multiple instances of the application are launched. For example, if I select 5 files, open 5 applications, how can I fix this?

+6
c # windows
source share
1 answer
+11
source share

All Articles