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);
}
}
}
}
관리자 권한으로 실행 하시겠습니까? + 어디에서 중단 점을 설정 했습니까? –
@BramVanStrydonck, 글쎄, 나는 코드가 꽤 괜찮다고 생각했기 때문에 어디로 설정해야할지 모르겠다. – uSeRnAmEhAhAhAhAhA
관리자로 시도해 보겠습니다. 아하. 그것은 관리자 계정입니다. 관리자로 망할 앱을 실행하지 않아도됩니다. – uSeRnAmEhAhAhAhAhA