【设置开机自启动】

 

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; }

 

posted on 2012-04-26 16:42  守望幸福的猪  阅读(5190)  评论(0编辑  收藏  举报