c#实现程序开机自动运行
代码如下:
RegistryKey KeyCon=Registry.LocalMachine.OpenSubKey(
"Software\\Microsoft\\Windows\\CurrentVersion\\Run",true);
string MyKey= "Terminal";
if((string)KeyCon.GetValue(MyKey,"no") == "no")//指定的键不存在
{
string Path = Application.StartupPath+@"\Terminal.exe";
KeyCon.SetValue(MyKey,Path); //设置注册表中的启动键
}