/// <summary>
2 /// 设置开机自动启用
3 /// </summary>
4 private void SetAutoStart()
5 {
6 try
7 {
8 string regPath = " SOFTWARE//Microsoft//Windows//CurrentVersion//Run " ;
9 string path = Application.ExecutablePath.ToLower(); // 将当前程序起动路径
10 string name = Path.GetFileName(path); // 获得应用程序名称
11 var regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regPath, true );
12 if (regKey == null ) regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(regPath);
13 regKey.SetValue(name, path);
14 }
15 catch
16 {
17 }
18 }
winform开机自动启动设置
最新推荐文章于 2024-07-03 09:26:25 发布