用C#怎样可以将自己写的程序放在services服务里,让他自动开机启动
用C#怎样可以将自己写的程序放在services服务里,让他自动开机启动啊?第一次接触这个,希望最好是有代码。。。。
谢谢!
程序代码: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");
