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 );}