如果想你寫的程序隨系統開機一起啟動的話,那么你可以照下面這個方法來做。
RunWhenStart(false, Application.ProductName, Application.StartupPath + @/"http://MUS.exe/");
/// <summary> /// 開機啟動項 /// </summary> /// <param name=/"Started/">是否啟動</param> /// <param name=/"name/">啟動值的名稱</param> /// <param name=/"path/">啟動程序的路徑</param> public static void RunWhenStart(bool Started, string name, string path) { RegistryKey HKLM = Registry.LocalMachine; RegistryKey Run = HKLM.CreateSubKey(@/"SOFTWARE//Microsoft//Windows//CurrentVersion//Run/"); if (Started == true) { try { Run.SetValue(name, path); HKLM.Close(); } catch (Exception Err) { MessageBox.Show(Err.Message.ToString(), /"MUS/", MessageBoxButtons.OK, MessageBoxIcon.Error); } } [Page] else { try { Run.DeleteValue(name); HKLM.Close(); } catch (Exception) { // } } }
新聞熱點
疑難解答