Boot up
1 //get the application path2 stringStrassname = Application.startuppath +@"\"+ Application.productname +@". EXE";3 //get the application name4 stringStrshortfilename =Application.productname;5 6 //Open the Registry base key "HKEY_LOCAL_MACHINE"7RegistryKey Rgkrun = Registry.LocalMachine.OpenSubKey ("Software\\microsoft\\windows\\currentversion\\run",true);8 if(Rgkrun = =NULL)9{//Create registry base entry "HKEY_LOCAL_MACHINE" if it does not existTenRgkrun = Registry.LocalMachine.CreateSubKey ("Software\\microsoft\\windows\\currentversion\\run"); OneMessageBox.Show ("Added boot success"); A } - - //sets the specified name/value pair for the specified registry key. If the specified item does not exist, the item is created. the Rgkrun.setvalue (Strshortfilename, strassname); -MessageBox.Show ("Added boot success");
Turn off boot
1 //get the application name2 stringStrshortfilename =Application.productname;3 4 //Open the Registry base key "HKEY_LOCAL_MACHINE"5RegistryKey Rgkrun = Registry.LocalMachine.OpenSubKey ("Software\\microsoft\\windows\\currentversion\\run",true);6 if(Rgkrun = =NULL)7{//Create registry base entry "HKEY_LOCAL_MACHINE" if it does not exist8Rgkrun = Registry.LocalMachine.CreateSubKey ("Software\\microsoft\\windows\\currentversion\\run");9MessageBox.Show ("Powered-on boot turned off");Ten } One A //deletes the specified name/value pair for the specified registry key. -Rgkrun.deletevalue (Strshortfilename,false); -MessageBox.Show ("Powered-on boot turned off");
C # WinForm Boot from