void AutoStart()
{
try
{
string regPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
string path = Application.ExecutablePath.ToLower(); //将当前程序起动路径
//MessageBox.Show(path);
string name = System.IO.Path.GetFileName(path); //获得应用程序名称
//MessageBox.Show(name);
var regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regPath, true);
if (regKey == null) regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(regPath);
regKey.SetValue(name, path);
}
catch
{
}
}