WinForm程序开机自动运行

修改注册表

1 RegistryKey hklm = Application.LocalMachine;
2 RegistryKey run = hklm.CreateSubKey(@"SOFTWARE\Microsoft\Windows\Current\Version\Run");
3 try
4 {
5 run.SetValue("tractor.exe","D:\\tractor.exe");
6 MessageBox.Show("注册表添加成功!!","提示",MessageBoxButton.OK, MessageBoxIcon.Information);
7 hklm.Close();
8 }
9
10 catch(Exception ee)
11 {
12 MessageBox.Show(my.Message.ToString(),"提示",MessageBoxButton.OK, MessageBoxIcon.Error);
13 }
14
posted @ 2011-06-22 10:10  王元勋  阅读(571)  评论(0编辑  收藏  举报