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

 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");

posted @ 2011-03-08 10:56  水木  阅读(257)  评论(0编辑  收藏  举报