读书人

小弟我想把小弟我写的c#程序随windows

发布时间: 2012-10-08 19:54:56 作者: rapoo

我想把我写的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");

读书人网 >windows

热点推荐