2023-03-24 17:02:04 +08:00
|
|
|
|
using Microsoft.Win32;
|
|
|
|
|
using System;
|
2023-03-24 09:58:42 +08:00
|
|
|
|
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()
|
|
|
|
|
{
|
2023-03-24 17:02:04 +08:00
|
|
|
|
AutoStart(true);
|
|
|
|
|
if(AuthorityCheck)
|
|
|
|
|
|
|
|
|
|
|
2023-03-24 09:58:42 +08:00
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
Application.Run(new MainFrm());
|
|
|
|
|
}
|
2023-03-24 17:02:04 +08:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-24 09:58:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|