天堂的狼

更好的生活,来自不懈的努力与拼搏,不要仅仅看中结果,拼搏的过程同样是精彩的!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::
RegistryKey KeyCon=Registry.LocalMachine.OpenSubKey( "Software\\Microsoft\\Windows\\CurrentVersion\\Run",true);

 string MyKey= "Terminal";

if((string)KeyCon.GetValue(MyKey,"no") == "no")//指定的键不存在

{ string Path = Application.StartupPath+@"\Terminal.exe"; KeyCon.SetValue(MyKey,Path);

 //设置注册表中的启动键 }

 

-------------

 

 //如果要取消的话就将KeyCon.SetValue(MyKey,Path);改成     

//KeyCon.SetValue(MyKey,false);

--说明:由于放在注册表 run中,用户必须登陆后才执行。
若在服务器上,机器重启,则不能使用该方式,要采用windows服务方式。

posted on 2008-11-11 13:25  天堂的狼  阅读(242)  评论(0编辑  收藏  举报