首页 > Windows开发 > 详细

C# 设置/取消程序 开机自启动

时间:2015-04-24 14:04:12      阅读:219      评论:0      收藏:0      [点我收藏+]
(修改注册表)
【设置开机自启动】
技术分享
using Microsoft.Win32;//添加命名空间

public static bool SetAutoRun(string keyName,string filePath) { try { RegistryKey runKey=Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true); runKey.SetValue(keyName,filePath); runKey.Close(); } catch { return false; } return true; }
技术分享

 

【取消开机自启动】

技术分享
using Microsoft.Win32;//添加命名空间

public static bool DeleteAutoRun(string keyName,string filePath) { try { RegistryKey runKey=Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true); runKey.DeleteValue(keyName,filePath); runKey.Close(); } catch { return false; } return true; }
另外一种方式,将对应的应用,或者应用的快捷方式放置在开始文件列表中。

C# 设置/取消程序 开机自启动

原文:http://www.cnblogs.com/Yellow0-0River/p/4453150.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!