怎样将程序设置为开机启动状态? 我在窗体中绘制了一个时钟,该时钟会显示当前时间。我想每天开机时该时钟都会自动弹出到我的桌面上,也就是说将我的程序设置为开机启动状态,我应该怎样实现怎样的功能? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你把它生成exe,然后在添加进任务计划中就行了吧。任务计划的操作网上有 //添加启动 RegistryKey ms_run = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); ms_run.SetValue("mistysoft", Application.ExecutablePath.ToString()); //删除启动(设为控,注册表项还在) RegistryKey ms_run = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); ms_run.SetValue("mistysoft", ""); 写注册表,放在SOFTWARE\Microsoft\Windows\CurrentVersion\Run下。/// <summary>/// 确定 按钮 事件(是否设置为开机自动启动)/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void Button4_Click(object sender, EventArgs e){if (autoCheck.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);}}} 把生成的exe文件直接拖入[开始]-->[所有程序]-->[启动]的后面就可以了 如何提高Remoting远程访问速度 菜鸟求教一个关于winform的问题 关于重置窗口的 小玩意.主板唱歌. 如何用listview来实现类似多label功能 如何根据配置文件的内容创建数据库中的表? C#和C++哪好呀? winform 打印 发货单 C#读取数据库写文本ID相同行连接 怎么在GridView双向排序的时侯加上向上和向下的箭头? WCF net.tcp 启动成功,客户端无法添加 Web References 请教C#Socket多连接异步编程问题? 如何另存一个Excel文件
RegistryKey ms_run = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
ms_run.SetValue("mistysoft", Application.ExecutablePath.ToString());
//删除启动(设为控,注册表项还在)
RegistryKey ms_run = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
ms_run.SetValue("mistysoft", "");
/// 确定 按钮 事件(是否设置为开机自动启动)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button4_Click(object sender, EventArgs e)
{
if (autoCheck.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);
}}
}