农村四月闲人少,勤学苦攻把名扬。这篇文章主要讲述WindowsFormsApp1设置开机自启动相关的知识,希望能为你提供帮助。
private void Form1_Load(object sender, EventArgs e) { SetAutoBootStatu(true); }
【WindowsFormsApp1设置开机自启动】
文章图片
/// < summary> /// 在注册表中添加、删除开机自启动键值 /// < /summary> public static int SetAutoBootStatu(bool isAutoBoot) { try { //RegistryKey rk = Registry.LocalMachine; //RegistryKey rk2 = rk.CreateSubKey("Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run"); //rk2.SetValue("MyExec", execPath); string execPath = Application.ExecutablePath; RegistryKey rk = Registry.LocalMachine; RegistryKey rk2 = rk.CreateSubKey("Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run"); if (isAutoBoot) { rk2.SetValue("MyExec", execPath); Console.WriteLine(string.Format("[注册表操作]添加注册表键值:path = {0}, key = {1}, value = https://www.songbingjia.com/android/{2} 成功", rk2.Name, "TuniuAutoboot", execPath)); } else { rk2.DeleteValue("MyExec", false); Console.WriteLine(string.Format("[注册表操作]删除注册表键值:path = {0}, key = {1} 成功", rk2.Name, "TuniuAutoboot")); } rk2.Close(); rk.Close(); return 0; } catch (Exception ex) { Console.WriteLine(string.Format("[注册表操作]向注册表写开机启动信息失败, Exception: {0}", ex.Message)); return -1; } }
推荐阅读
- android activity状态的保存
- HBuilder webApp开发 Websql增删改查操作
- 我的Android进阶之旅------&gt;Android中android:windowSoftInputMode的使用方法
- Android实现RecyclerView的下拉刷新和上拉载入很多其它
- 摆脱命令行,Ubuntu下配置Android开发环境
- Azure Mobile App - Custom Authentication
- Android文件访问
- app 耗电优化之三 使用JobSchedule对任务进行合理排期
- app耗电优化之二使用电源管理来安排任务