2009-12-10 76 views
6

我正在編寫一個C#應用程序,它將文件作爲參數,我將它添加到帶有下面列出的代碼的shell上下文菜單中;從C#上的Windows shell上下文菜單中取出多個文件(參數)

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

它運行良好,但如果我選擇多個文件,應用程序運行的多個實例。 例如,如果我選擇5個文件5應用程序正在打開,我該如何解決這個問題?

回答