using System.Windows.Forms;
using System.Data;
using System.Globalization;
using System.Configuration;
using System.Diagnostics;
namespace my_application
{
public class form1 : System.Windows.Forms.Form
{
private static bool m_blnRunning = false;
[STAThread]
static void Main()
{
Find("myapplication"); //myapplication is my solution name.
if (m_blnRunning == true)
{
MessageBox.Show("Application is already running!");
return;
}
Application.Run();
}
private static void Find(string processName)
{
int intCount = 0;
try
{
foreach (Process thisproc in Process.GetProcessesByName(processName))
{
intCount = intCount + 1;
if ((intCount == 2))
{
m_blnRunning = true;
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}