我在窗体中绘制了一个时钟,该时钟会显示当前时间。我想每天开机时该时钟都会自动弹出到我的桌面上,也就是说将我的程序设置为开机启动状态,我应该怎样实现怎样的功能?

解决方案 »

  1.   

    你把它生成exe,然后在添加进任务计划中就行了吧。任务计划的操作网上有
      

  2.   

       //添加启动
       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", "");
      

  3.   

    写注册表,放在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);
    }}
    }
      

  4.   

    把生成的exe文件直接拖入[开始]-->[所有程序]-->[启动]的后面就可以了