Create a new WinForm drag a checkbox in.
Then set its changed event.
It has been tested and can be copied directly.
Private voidCheckbox1_checkedchanged (Objectsender, EventArgs e) { if(checkbox1.checked)//set up boot from{MessageBox.Show ("to set up boot-up, you need to modify the registry","Tips");//hovertree.com stringPath =Application.executablepath; RegistryKey RK=Registry.localmachine; RegistryKey RK2= RK. CreateSubKey (@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); Rk2. SetValue ("Jcshutdown", path); Rk2. Close (); Rk. Close (); } Else //Cancel boot from boot{MessageBox.Show ("to cancel the boot, you need to modify the registry","Tips"); stringPath =Application.executablepath; RegistryKey RK=Registry.localmachine; RegistryKey RK2= RK. CreateSubKey (@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); Rk2. DeleteValue ("Jcshutdown",false); Rk2. Close (); Rk. Close (); } }
Http://www.cnblogs.com/sosoft
C # Power-on auto-start program code