C # random startup of applications

Source: Internet
Author: User

if you want to write the Program that starts with the system startup, you can follow the following method.
runwhenstart (false, application. productname, application. startuppath + @ \ "\ mus.exe \");

/// <Summary> /// start item /// </Summary> /// <Param name = \ "started \"> whether to start </param> /// <Param name = \ "Name \"> name of the startup value </param> /// <Param name = \ "path \"> path of the Startup Program </param> Public static void runwhenstart (bool bstarted, string name, string path) {registrykey HKLM = registry. localmachine; registrykey run = HKLM. createsubkey (@ "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run \"); try {If (bstarted) {run. setvalue (name, PATH);} else {run. deletevalue (name) ;}} catch (exception ERR) {MessageBox. show (err. message. tostring (), "system prompt", messageboxbuttons. OK, messageboxicon. error);} finally {HKLM. close (); run. close ();}}

Add a checkbox that is displayed on the user interface at startup, and add a checkedchanged event, that is, you can use the checkbox to set whether to start at any time.

 
/// <Summary> /// set automatic start upon startup /// </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> private void chrb_checkedchanged (Object sender, eventargs e) {string startpath = application. executablepath; runwhenstart (chrb. checked, "sendmessage", startpath );}

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.