程序开机自动运行

2007/7/21 13:32:16


阅读全文(3056) | 回复(1) | 编辑 | 精华

cpf20072008 @ 2007-07-13 08:45 string StartupPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup);              System.IO.File.Copy("应用程序路径(包括程序名)", StartupPath + "执行程序文件名称", true);                  //获得文件的当前路径                 string dir = Directory.GetCurrentDirectory();               //获取可执行文件的全部路径                 string exeDir = dir + "WindowsApplication1.exe";                     //获取Run键               RegistryKey   key1=Registry.LocalMachine;               RegistryKey   key2=key1.CreateSubKey("SOFTWARE");               RegistryKey   key3=key2.CreateSubKey("Microsoft");               RegistryKey   key4=key3.CreateSubKey("Windows");               RegistryKey   key5=key4.CreateSubKey("CurrentVersion");               RegistryKey   key6=key5.CreateSubKey("Run");               //在Run键中写入一个新的键值               key6.SetValue("myForm",exeDir);               key6.Close();                   //如果要取消的话就将key6.SetValue("myForm",exeDir);改成               //key6.SetValue("myForm",false);

Qr

Posted by Qr on 2007/7/21 13:32:16

回复:程序开机自动运行

2007/7/22 9:44:43


个人主页 | 引用回复 | 主人回复 | 返回 | 编辑 | 删除

//获得文件的当前路径     string dir = Directory.GetCurrentDirectory();    //获取可执行文件的全部路径      string exeDir = dir + "WindowsApplication1.exe";    

hjx_221

Posted by hjx_221 on 2007/7/22 9:44:43

» 1 »

发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)
站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.031 second(s), page refreshed 144777586 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号