设置winform 自动启动

private void SetAutoStart()
{
try
{
string regPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
string path = Application.ExecutablePath.ToLower();
string name = System.IO.Path.GetFileName(path);
var regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regPath, true);
if (regKey == null) regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(regPath);
regKey.SetValue(name, path);
}
catch { }
}

设置winform 自动启动

上一篇:Windows 特殊文件夹


下一篇:windows server 2003