RunWhenStart(false, Application.ProductName, Application.StartupPath + @\"\\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)
{
//
}
}
}
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。