程序开机自动运行
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);
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";
Posted by hjx_221 on 2007/7/22 9:44:43
发表评论: |