tring mutexName = "e50cf829-f6b9-471e-8d9f-67eac3699f09";
bool grantedOwnership;
//we prefix the mutexName with "Local\\" to allow this to run under terminal services.
//The "Local\\" prefix forces this into local user space.
//If we want to forbid this in TS, use the "Global\\" prefix.
Mutex singleInstanceMutex = new Mutex(true, "Global\\" + mutexName, out grantedOwnership);
try
{
if (!grantedOwnership)
{
Application.Exit();
}