C# 透過修改註冊表(REG)設定開機 啟動​C# 透過修改註冊表(REG)設定開機程式(軟體)自動啟動(Auto Run)​

C# 透過修改註冊表(REG)設定開機 啟動​C# 透過修改註冊表(REG)設定開機程式(軟體)自動啟動(Auto Run)​

C# 透過修改註冊表(REG)設定開機 程式(軟體)自動啟動(Auto Run)


 

資料來源: http://www.cnblogs.com/daban/archive/2012/10/26/2740583.html

 

 關鍵字:CreateSubKey、Registry.LocalMachine、RegistryKey、MessageBox.Show、SetValue、DeleteValue、UAC、登錄資料庫、註冊表


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using Microsoft.Win32;

 

namespace CS_Boot_Run

{

    //MeALOP?

    //http://www.cnblogs.com/daban/archive/2012/10/26/27…

    //g!D2¡PwLtITzIÓOXE

 

    public partial class Form1 : Form

    {

        public
Form1()

        {

            InitializeComponent();

        }

 

        private
void button1_Click(object
sender, EventArgs e)

        {

            //oLug!XoaMo|..

            string
starupPath = Application.ExecutablePath;

            //class
Micosoft.Win32.RegistryKey.
iDUWindowguDUi?£gÂAM`I,1tOguDUiME.

            RegistryKey
loca = Registry.LocalMachine;

            RegistryKey
run = loca.CreateSubKey(@”SOFTWARE\Microsoft\Windows\CurrentVersion\Run”);

 

            try

            {

                //SetValue:sxEoWU

                run.SetValue(“csbootrun”, starupPath);

                MessageBox.Show(wÓODI¡ÒBa!”, ¦¢GDU”, MessageBoxButtons.OK,
MessageBoxIcon.Information);

                loca.Close();

            }

           
catch (Exception
ee)

            {

                MessageBox.Show(ee.Message.ToString(),
¦¢GDU”, MessageBoxButtons.OK,
MessageBoxIcon.Error);

            }

        }

 

        private
void button2_Click(object
sender, EventArgs e)

        {

           
// MessageBox.Show(“
LS3i?”);

            //oLug!XoaMo|..

            string
starupPath = Application.ExecutablePath;

            //class
Micosoft.Win32.RegistryKey.
iDUWindowguDUi?£gÂAM`I,1tOguDUiME.

            RegistryKey
loca = Registry.LocalMachine;

            RegistryKey
run = loca.CreateSubKey(@”SOFTWARE\Microsoft\Windows\CurrentVersion\Run”);

 

            try

            {

                //SetValue:sxEoWU

                run.DeleteValue(“csbootrun”);

                MessageBox.Show(wX¡Ói¡ÒBa!”, ¦¢GDU”, MessageBoxButtons.OK,
MessageBoxIcon.Information);

                loca.Close();

            }

            catch
(Exception ee)

            {

                MessageBox.Show(ee.Message.ToString(),
¦¢GDU”, MessageBoxButtons.OK,
MessageBoxIcon.Error);

            }

        }

    }

}

 

_

 


 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *