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

2011-01-03 08:35
2011-01-03 09:38
2011-01-04 17:24
2011-01-06 12:58