C # WinForm Boot from

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.