使程序开机自启
发布时间:2020-12-14 02:35:14 所属栏目:Windows 来源:网络整理
导读:实现效果: ? ? 知识运用: 注册表项:[ HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun ] ? 下的键值对 实现代码: private void button2_Click(object sender,EventArgs e) { if (textBox1.Text != "") { string pro = textBox1.Text.
实现效果: ? ? 知识运用: 注册表项:[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun]?下的键值对 实现代码: private void button2_Click(object sender,EventArgs e) { if (textBox1.Text != "") { string pro = textBox1.Text.Trim(); string proName = textBox1.Text.Substring(pro.LastIndexOf("")+1); //获取文件名 RegistryKey rk=Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun",true); if (rk ==null) //如果指定项不存在 rk = Registry.LocalMachine.CreateSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun"); rk.SetValue(proName,pro); if (MessageBox.Show("设置成功!") == DialogResult.OK) RefreshSystem(); //刷新系统 } } private void button3_Click(object sender,EventArgs e) { if (textBox1.Text != "") { try { string pro = textBox1.Text.Trim(); string proName = textBox1.Text.Substring(pro.LastIndexOf("") + 1); //获取文件名 RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun",true); if (rk == null) //如果指定项不存在 rk = Registry.LocalMachine.CreateSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun"); rk.DeleteValue(proName); if (MessageBox.Show("设置成功!") == DialogResult.OK) RefreshSystem(); } catch{} } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- active-directory – 使Active Directory更改为原子
- 如何优化升级RStudio和R并保留项目文件和所有设置(Windows机
- 窗口 – 如何保护软件免受系统日期更改?
- 存储空间稍后添加镜像驱动器
- 远程访问Windows Vista到Mac OSX?
- winapi – 如何从Cygwin程序中调用Win32 API
- active-directory – 在仅限Windows的商店中通过Internet验
- win10安装navisworks失败,怎么强力卸载删除注册表并重新安
- 如何在Windows中的接口状态更改上运行脚本?
- 在Windows上运行远程命令,如linux上的ssh -c