private void btnSetOk_Click(object sender, EventArgs e)
{
RegCompStartRun(true, ());
}
private void btnCancel_Click(object sender, EventArgs e)
{
RegCompStartRun(false, ());
}
private void RegCompStartRun(bool cmd, string argPath)
{
string starupPath = argPath;
if ((argPath))
{
//Get the full path of the current executable program
starupPath = ;
}
//Indicates that the key-level node in the Window registry is read from the Windows registry base key HKEY_LOCAL_MACHINE
Microsoft. loca = Microsoft.;
Microsoft. run = (@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
try
{
//SetValue: The name of the stored value
if (cmd)
{
("AutoStartupTestWinFormApp", starupPath);// Join the registration, parameter 1 is the name of the registered node (at will be at will)
= "Setting successfully!";
}
else
{
("AutoStartupTestWinFormApp", false);//Delete the registered node
= "Unset was successfully cancelled!";
}
();
}
catch (Exception ee)
{
((), "hint", , );
}
}