C#完成法式開機啟動的辦法。本站提示廣大學習愛好者:(C#完成法式開機啟動的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#完成法式開機啟動的辦法正文
本文實例講述了C#完成法式開機啟動的辦法。分享給年夜家供年夜家參考,詳細以下:
//此辦法把啟動項加載到注冊表中 //取得運用法式途徑 string strAssName = Application.StartupPath + @"\" + Application.ProductName + @".exe"; //取得運用法式名 string ShortFileName = Application.ProductName; RegistryKey rgkRun = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (rgkRun == null) { rgkRun = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); } rgkRun.SetValue(ShortFileName, strAssName); //此刪除注冊表中啟動項 //取得運用法式名 string ShortFileName = Application.ProductName; RegistryKey rgkRun = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (rgkRun == null) { rgkRun = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); } rgkRun.DeleteValue(ShortFileName, false);
願望本文所述對年夜家C#法式設計有所贊助。