45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Windows.Forms;
|
|
|
|
namespace JiraTimeBotForm
|
|
{
|
|
static class Program
|
|
{
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main()
|
|
{
|
|
if (PriorProcess() != null)
|
|
{
|
|
|
|
MessageBox.Show("Another instance of the app is already running.");
|
|
return;
|
|
}
|
|
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.Run(new frmMain());
|
|
}
|
|
|
|
public static Process PriorProcess()
|
|
// Returns a System.Diagnostics.Process pointing to
|
|
// a pre-existing process with the same name as the
|
|
// current one, if any; or null if the current process
|
|
// is unique.
|
|
{
|
|
Process curr = Process.GetCurrentProcess();
|
|
Process[] procs = Process.GetProcessesByName(curr.ProcessName);
|
|
foreach (Process p in procs)
|
|
{
|
|
if ((p.Id != curr.Id) &&
|
|
(p.MainModule.FileName == curr.MainModule.FileName))
|
|
return p;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|