초기 커밋.
This commit is contained in:
59
ssgrestserver/Program.cs
Normal file
59
ssgrestserver/Program.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
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 ssgrestserver
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 해당 응용 프로그램의 주 진입점입니다.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
System.Diagnostics.Process[] processes = null;
|
||||
string processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToUpper();
|
||||
processes = System.Diagnostics.Process.GetProcessesByName(processName);
|
||||
if (processes.Length > 2)
|
||||
{
|
||||
MessageBox.Show("프로그램이 이미 실행중입니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsAdministrator() == false)
|
||||
{
|
||||
ProcessStartInfo procInfo = new ProcessStartInfo();
|
||||
procInfo.UseShellExecute = true;
|
||||
procInfo.FileName = Application.ExecutablePath;
|
||||
procInfo.WorkingDirectory = Environment.CurrentDirectory;
|
||||
procInfo.Verb = "runas";
|
||||
Process.Start(procInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
mainForm = new Form1();
|
||||
Application.Run(mainForm);
|
||||
}
|
||||
}
|
||||
public static Form1 mainForm;
|
||||
|
||||
public static bool IsAdministrator()
|
||||
{
|
||||
WindowsIdentity identity = WindowsIdentity.GetCurrent();
|
||||
|
||||
if (identity != null)
|
||||
{
|
||||
WindowsPrincipal principal = new WindowsPrincipal(identity);
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user