XKRS2023Frm/CopyCode/Program.cs
2023-03-24 17:02:04 +08:00

49 lines
1.5 KiB
C#

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace XKRS.UI.Main
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
AutoStart(true);
if(AuthorityCheck)
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainFrm());
}
private static void AutoStart(bool isAuto = true)
{
if (isAuto == true)
{
RegistryKey R_local = Registry.CurrentUser;//包含有关当前用户首选项的信息
//创建一个新子项或打开一个现有子项进行写访问
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
R_run.SetValue("ProjectName", Application.ExecutablePath);//获取启动应用程序的可执行文件的路径
R_run.Close();
R_local.Close();
}
else
{
RegistryKey R_local = Registry.CurrentUser;
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
R_run.DeleteValue("ProjectName", false);
R_run.Close();
R_local.Close();
}
}
}
}