C#實(shí)現(xiàn)將應(yīng)用程序設(shè)置為開機(jī)啟動(dòng)的方法
更新時(shí)間:2015年09月23日 15:36:43 作者:我心依舊
這篇文章主要介紹了C#實(shí)現(xiàn)將應(yīng)用程序設(shè)置為開機(jī)啟動(dòng)的方法,涉及C#針對(duì)注冊(cè)表的寫入技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了C#實(shí)現(xiàn)將應(yīng)用程序設(shè)置為開機(jī)啟動(dòng)的方法。分享給大家供大家參考。具體如下:
private void WriteRegistry() { string strName = Application.ExecutablePath; if (File.Exists(strName)) { string strNewName = Path.GetFileName(strName); RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (reg == null) { reg = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); } else { if (reg.GetValue(strNewName) == null) { reg.SetValue(strNewName, strName); } } } }
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
C#中Dictionary與List的用法區(qū)別以及聯(lián)系詳解
List和Dictionary想必是我們平常用到最多的C#容器了,他們使用起來都很簡單,這篇文章主要給大家介紹了關(guān)于C#中Dictionary與List的用法區(qū)別以及聯(lián)系的相關(guān)資料,需要的朋友可以參考下2023-11-11對(duì)C#中public、private、protect的區(qū)別說明
這篇文章主要介紹了對(duì)C#中public、private、protect的區(qū)別說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-04-04