通过添加删除注册表键值控制应用程序的自启动
来源:互联网 发布:slam算法简介 编辑:程序博客网 时间:2024/06/05 17:43
private 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;
}
private static bool DeleteAutoRun(string keyName)
{
try
{
RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
runKey.DeleteValue(keyName);
runKey.Close();
}
catch
{
return false;
}
return true;
{
try
{
RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
runKey.SetValue(keyName, filePath);
runKey.Close();
}
catch
{
return false;
}
return true;
}
private static bool DeleteAutoRun(string keyName)
{
try
{
RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
runKey.DeleteValue(keyName);
runKey.Close();
}
catch
{
return false;
}
return true;
}
调用:
IsAutoRun = AppConfig.GetAutoRun();
if (IsAutoRun)
{
SetAutoRun("应用程序名称", Application.ExecutablePath);
}
else
{
DeleteAutoRun("应用程序名称");
}
- 通过添加删除注册表键值控制应用程序的自启动
- 程序自启动,注册表键值的位置
- 注册表操作:添加键值、删除键值、删除子键
- Wince应用程序开机自启动的注册表设置
- Wince应用程序开机自启动的注册表设置
- [转]Wince应用程序开机自启动的注册表设置
- WIN CE下通过注册表键值控制RIL模块的扩展功能
- WIN CE下通过注册表键值控制RIL模块的扩展功能
- WIN CE下通过注册表键值控制RIL模块的扩展功能
- WIN CE下通过注册表键值控制RIL模块的扩展功能
- VC++删除注册表键值
- 删除注册表键值
- 注册表REG文件编写实例(创建、删除、添加、更改键值)
- 删除msconfig里的启动记录(通过注册表实现)
- 递归删除注册表与获取注册表的一个键值
- 操作注册表添加/删除系统的启动项
- openwrt 添加应用程序自启动
- 通过注册表添加删除系统服务
- Linux培训之教你轻松学习shell变量的使用
- a[b]和b[a]区别
- hdu 4263 (最小生成树)
- 为什么TCP存在重传
- win server 2003 事件查看器中的事件ID
- 通过添加删除注册表键值控制应用程序的自启动
- Python进阶08 错误处理
- UVa 568 Just the Facts (数论&打表&不打表)
- My Favorite Math Book
- /*深度优先建立深林,孩子兄弟法*/
- 利用App.Config保存系统工作参数
- 试论【函数指针】与【指针函数】
- 蓝牙FAQ
- UVa 350 Pseudo-Random Numbers (伪随机数的循环长度)