How about using a Mutex? This should also work for Terminal Services sessions. Use in Program.cs
static Mutex mut;
try
{
bool isOwned = false;
mut = new Mutex(true, Application.ProductName + " MUTEX: {53A4988C-F91F-4054-9076-220AC5EC03F3}", out isOwned);
if (!isOwned)
{
MessageBox.Show(Application.ProductName + " is already running on this machine.",
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
Application.Run(new Form1());
}
finally
{
try
{
mut.ReleaseMutex();
}
catch (ApplicationException)
{
}
}