HelloWord 发表于 2017-8-16 18:04:15

C#WinForm开机启动程序下载

本帖最后由 HelloWord 于 2017-8-16 18:11 编辑

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 开机自动启动
{
    public partial class Form1 : Form
    {
      public Form1()
      {
            InitializeComponent();
      }

      private void checkBox1_CheckedChanged(object sender, EventArgs e)
      {
            if (checkBox1.Checked) //设置开机自启动
            {
                MessageBox.Show("设置开机自启动,需要修改注册表", "提示");
                string path = Application.ExecutablePath;
                RegistryKey rk = Registry.LocalMachine;
                RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                rk2.SetValue("JcShutdown", path);
                rk2.Close();
                rk.Close();
            }
            else //取消开机自启动
            {
                MessageBox.Show("取消开机自启动,需要修改注册表", "提示");
                string path = Application.ExecutablePath;
                RegistryKey rk = Registry.LocalMachine;
                RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                rk2.DeleteValue("JcShutdown", false);
                rk2.Close();
                rk.Close();
            }
      }

      private void Form1_Load(object sender, EventArgs e)
      {
            string path = Application.ExecutablePath;
            RegistryKey rk = Registry.LocalMachine;
            RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
            rk2.DeleteValue("rizhi", false);
            rk2.Close();
            rk.Close();
      }
    }
}
HelloWord出品必属精品
{:4_91:}
以上只是部分代码{:4_115:}全代码回复后获取下载地址:**** Hidden Message *****

z857052037 发表于 2017-8-16 18:57:59

回帖是美德,看贴必回

正义善良好少年i 发表于 2017-8-17 11:18:33

回帖是美德,看贴必回

398681207 发表于 2017-9-3 23:51:02

回的人少,我来小顶一下

qq123456 发表于 2017-10-24 13:09:01

啥也不说了,感谢楼主分享哇!

孽安逸 发表于 2019-2-3 16:31:53

回帖是美德,看贴必回
页: [1]
查看完整版本: C#WinForm开机启动程序下载