日期:2014-05-17 浏览次数:20766 次
string KJLJ = Application.ExecutablePath;
if (!System.IO.File.Exists(KJLJ))//判断指定文件是否存在
return;
string newKJLJ = KJLJ.Substring(KJLJ.LastIndexOf("\\") + 1);
RegistryKey Rkey =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (Rkey == null)
Rkey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
Rkey.SetValue(newKJLJ, KJLJ);
MessageBox.Show("程序设置完毕,请重新启动计算机后即可生效!", "程序员的爬行温馨提醒", MessageBoxButtons.OK, MessageBoxIcon.Information);