C#程序开机自启以及最小化到托盘
2014-07-05 09:58
453 查看
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
//获取程序执行路径..
string starupPath = Application.ExecutablePath;
//class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
try
{
//SetValue:存储值的名称
run.SetValue("qidong", starupPath);
/// MessageBox.Show("已启用开机运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
loca.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
// MessageBox.Show("没有选中");
//获取程序执行路径..
string starupPath = Application.ExecutablePath;
//class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
try
{
//SetValue:存储值的名称
run.DeleteValue("qidong");
MessageBox.Show("已停止开机运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
loca.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
this.Hide();
}
private void notifyIcon1_MouseDown(object sender, MouseEventArgs e)
{
this.Show();
// this.WindowState = FormWindowState.Maximized;
notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}
{
if (checkBox1.Checked == true)
{
//获取程序执行路径..
string starupPath = Application.ExecutablePath;
//class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
try
{
//SetValue:存储值的名称
run.SetValue("qidong", starupPath);
/// MessageBox.Show("已启用开机运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
loca.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
// MessageBox.Show("没有选中");
//获取程序执行路径..
string starupPath = Application.ExecutablePath;
//class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
try
{
//SetValue:存储值的名称
run.DeleteValue("qidong");
MessageBox.Show("已停止开机运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
loca.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
this.Hide();
}
private void notifyIcon1_MouseDown(object sender, MouseEventArgs e)
{
this.Show();
// this.WindowState = FormWindowState.Maximized;
notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}
相关文章推荐
- C#WinForm程序最小化后在托盘中隐藏方法以及几个关键点的简单分析
- C# 实现程序最小化到托盘
- C#winform中怎么将程序最小化到系统托盘
- C#程序最小化到托盘图标
- C# winForm程序开机启动和托盘显示
- C#winform中怎么将程序最小化到系统托盘
- C#winform中怎么将程序最小化到系统托盘
- C# WF程序 开机启动和托盘显示
- C# winForm程序开机启动和托盘显示[转]
- C# winform 开机自启动时最小化到托盘 单击显示窗体,右击显示菜单
- C#winform中怎么将程序最小化到系统托盘
- c# 程序最小化到系统托盘
- C# WinForm程序最小化到托盘
- C# 托盘程序 实例 双击显示窗体,最小化到托盘
- C#实现WinForm程序的动态系统托图标 关闭主窗体时最小化到系统托盘
- C#实现winform软件开机自动启动并最小化到系统托盘
- C#实现winform软件开机自动启动并最小化到系统托盘
- C#winform中怎么将程序最小化到系统托盘
- 如何使程序最小化时出现在系统托盘中(C#)
- c#中程序最小化到托盘