시작할 때 내 응용 프로그램을 실행하려고했습니다. 이 기능을 켜고 끌 수있는 컨텍스트 메뉴를 추가했습니다. 상황에 맞는 메뉴의 왼쪽에는 "확인"기능이 활성화되어 있습니다 (선택하면 체크 표시가 나타납니다).시작시 응용 프로그램 실행
//
// menu_startup
//
this.menu_startup.Name = "menu_startup";
this.menu_startup.ShortcutKeyDisplayString = "";
this.menu_startup.Size = new System.Drawing.Size(201, 22);
this.menu_startup.Text = "Run on startup";
this.menu_startup.Click += new System.EventHandler(this.menu_startup_Click);
는 그리고 이것은 내가 내가 잘못 여기서 뭐하는 거지 볼 수 없습니다 Form1.cs를
public string regKey = "IMGit";
public Form1()
{
InitializeComponent();
notifyIcon1.ContextMenuStrip = contextMenuStrip1;
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (rkApp.GetValue(this.regKey) == null)
{
this.menu_startup.Checked = false;
}
else
{
this.menu_startup.Checked = true;
}
this.menu_about.Click += menu_about_Click; // Ignore
this.menu_exit.Click += menu_exit_Click; // Ignore
this.menu_startup.Click += menu_startup_Click;
}
private void menu_startup_Click(object sender, EventArgs e)
{
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (rkApp.GetValue(this.regKey) == null)
{
rkApp.SetValue(this.regKey, Application.ExecutablePath.ToString());
}
else
{
rkApp.DeleteValue(this.regKey, false);
}
}
에서했던 것입니다. 이 내 응용 프로그램에 대한 새 레지스트리 항목을 설정해야합니다.
생성자에서 레지스트리 항목을 만들 때 코드 줄을 추가하면 항목이 올바르게 생성됩니다.
아이디어가 있으십니까?
프로젝트 설정을 시도 했습니까? 거기에 값을주고 해당 값과 같은지 확인하고 설정을로드하십시오. – coder
어떻게해야할지 모르겠다. – Aborted
다음 링크는 http://msdn.microsoft.com/en-us/library/vstudio/25zf0ze8(v=vs.100).aspx – coder