hello friends,
how to check my application file runing or not if already runing then it should say arealy logged in when i double click on Icon or exe..
reply me ASAP...
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted May 21, 2011, 3:57 AM
bool WasCreated;
const string MutexName = "WhateverNameYouWant";
Mutex m = new Mutex(true, MutexName, out WasCreated);
if (!WasCreated)
{
// MessageBox.Show("A previous instance exists");
return;
}
Also, after the "Application.Run(new Form1());" you need to also do the following:
GC.KeepAlive(m);
That line is not important for small programs, but always use it anyway when using the above code that uses the Mutex.
Posted May 20, 2011, 5:48 AM
System.Diagnostics.Process[] process= System.Diagnostics.Process.GetProcessesByName("exeName");
if (process.Length > 0)
MessageBox.Show("Application is already running");