static void Main(string[] args)
{
Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
AutoRun();
Application.Run(new Worker());
}
static void AutoRun()
{
RegistryKey myKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\",true);
myKey.SetValue("StudyIcon", Application.ExecutablePath);
}
}
class Worker : ApplicationContext
{
private static NotifyIcon icon;
public Worker()
{
icon = new NotifyIcon();
icon.Icon = new Icon("icon.ico");
icon.Text = "Test";
icon.Visible = true;
icon.Click += OnClickIcon;
icon.MouseMove += OnEnterIcon;
this.ThreadExit += OnExit;
}
private void OnClickIcon(object sender, EventArgs e)
{
this.ExitThread(); // когда кликаете на иконку, то программа выключается.
}
private void OnExit(object sender, EventArgs e)
{
icon.Dispose();// выключаем иконку, чтобы не осталась на панели задач
}
}
Как сделать, что бы запихнуть запуск программы в private void OnClickIcon