标签:winform blog ar io os for on div art
1.程序运行时调用下面方法即可。
/// <summary> /// 设置开机自动启用 /// </summary> private void SetAutoStart() { try { string regPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";//注册表 string path = Application.ExecutablePath.ToLower(); //获取.exe当前程序路径 //MessageBox.Show(path); string name = Path.GetFileName(path); //获得应用程序名称 //MessageBox.Show(name); 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 blog ar io os for on div art
原文地址:http://www.cnblogs.com/Evan-Pei/p/4171614.html