您的位置:首页 > 编程语言 > C#

我想把我写的c#程序随windows启动(开机启动), 我该怎么写呢

2011-03-08 10:56 555 查看
public static bool SetAutoRun(string keyName,string filePath)
{
try
{
RegistryKey runKey=Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true);
runKey.SetValue(keyName,filePath);
runKey.Close();
}
catch
{
return false;
}
return true;
}

test: SetAutoRun("myexe","c:\\text.exe");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: