C#设置程序开机自启动

private void setStart_Click(object sender, EventArgs e)
        {
            RegistryKey R_local = Registry.LocalMachine; 
            RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";);
            R_run.SetValue("test", Application.ExecutablePath);
            R_run.Close();
            R_local.Close();
        }
private void button3_Click(object sender, EventArgs e)
        {
            RegistryKey R_local = Registry.LocalMachine; 
            RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
            R_run.DeleteValue("test", false);
            R_run.Close();
            R_local.Close();
        }
C#设置程序开机自启动
https://blog.async.website/index.php/archives/3099/
本文作者 snowysong@live.com
发布时间 2022-05-23
许可协议 CC BY-NC-SA 4.0
发表新评论