How to add the. NET program to the startup Item
Private void regcompstartrun (bool cmd) {// obtain the program execution path .. string staruppath = application. executablepath; // indicates the entry-level node in the Window registry. It reads the HKEY_LOCAL_MACHINE registrykey loca = registry in the Windows registry. localmachine; registrykey run = loca. createsubkey (@ "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run"); lbldisplay. text + = "execution successful! "; Try {// setvalue: name of the stored value if (CMD) {run. setvalue ("winform", staruppath); // Add to registration. Parameter 1 is the name of the registered node (random)} else {run. deletevalue ("winform", false); // Delete this registered node} loca. close ();} catch (exception ee) {MessageBox. show (EE. message. tostring (), "prompt", messageboxbuttons. OK, messageboxicon. error );}}
With this, the winform program can be automatically run at startup.