2013-11-27 3 views
0

Explorer 메뉴에서 새 Menuitem을 배치하려고하는데 작동하지 않습니다.컨텍스트 메뉴 항목이 표시되지 않습니다.

예외 나 오류 메시지가 표시되지 않고 중단 점을 설정했으나 충돌이 발생하지 않았습니다. 그리고 레지스트리를 검색했는데 거기에 없습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

private const string MenuName = "Folder\\shell\\NewMenuOption"; 
    private const string Command = "Folder\\shell\\NewMenuOption\\command"; 

    private void Form1_Shown(object sender, EventArgs e) 
    { 
     using(var folder = new FolderBrowserDialog()) 
     { 
      if(folder.ShowDialog() == System.Windows.Forms.DialogResult.OK) 
      { 
       Properties.Settings.Default.ArchivePath = folder.SelectedPath; 
       Properties.Settings.Default.Save(); 

       RegistryKey regmenu = null; 
       RegistryKey regcmd = null; 
       try 
       { 
        regmenu = Registry.ClassesRoot.CreateSubKey(MenuName); 
        if (regmenu != null) 
         regmenu.SetValue("", "Archive"); 
        regcmd = Registry.ClassesRoot.CreateSubKey(Command); 
        if (regcmd != null) 
         regcmd.SetValue("", Environment.CurrentDirectory + @"\Archiver.exe"); 
       } 
       catch (Exception ex) 
       { 
        MessageBox.Show(this, ex.ToString()); 
       } 
       finally 
       { 
        if (regmenu != null) 
         regmenu.Close(); 
        if (regcmd != null) 
         regcmd.Close(); 
       } 
      } 
      else 
      { 
       if(MessageBox.Show("In order to use Archiver, you must first specify where your archive is. Do you want to continue?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) 
       { 
        Application.Restart(); 
       } 
       else 
       { 
        this.Dispose(true); 
       } 
      } 
     } 
    } 
+1

관리자 권한으로 실행 하시겠습니까? + 어디에서 중단 점을 설정 했습니까? –

+0

@BramVanStrydonck, 글쎄, 나는 코드가 꽤 괜찮다고 생각했기 때문에 어디로 설정해야할지 모르겠다. – uSeRnAmEhAhAhAhAhA

+0

관리자로 시도해 보겠습니다. 아하. 그것은 관리자 계정입니다. 관리자로 망할 앱을 실행하지 않아도됩니다. – uSeRnAmEhAhAhAhAhA

답변

5

앱을 관리자로 실행하십시오. 레지스터를 변경하려면 관리자 권한이 필요할 수 있습니다.

+1

이 필요할 수도 있습니다.) 시스템에 무언가를 변경하는 작업은 완전 무결성 모드로 실행해야합니다. http://msdn.microsoft.com/en-us/library/aa970910 (v = 1.10) .aspx – woutervs

관련 문제