//注册表操作
public void RunWhenStart(bool Started, string name, string path)
{RegistryKey HKLM = Registry.LocalMachine;
RegistryKey Run = HKLM.CreateSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/Run");
if (Started == true)
{
try
{
Run.SetValue(name, path);
HKLM.Close();
}
catch//没有权限会异常
{ }
}
else
{
try
{
Run.DeleteValue(name);
HKLM.Close();
}
catch//没有权限会异常
{ }
}
}