Files
2026-04-01 20:20:09 +09:00

64 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace updateServer
{
static class Program
{
/// <summary>
/// 해당 응용 프로그램의 주 진입점입니다.
/// </summary>
[STAThread]
static void Main()
{
/*
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mMainForm = new Form1();
Application.Run(mMainForm);
*/
if (IsAdministrator() == false)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.UseShellExecute = true;
processStartInfo.FileName = Application.ExecutablePath;
processStartInfo.WorkingDirectory = Environment.CurrentDirectory;
processStartInfo.Verb = "runas";
Process.Start(processStartInfo);
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mMainForm = new Form1();
Application.Run(mMainForm);
}
}
public static bool IsAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
if (identity != null)
{
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
return false;
}
public static Form1 mMainForm = null;
}
}