hello friends,
do you have any idea how to check EXE file if its already Run... if its run then its should be show Error....
Thanks in Advance
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rafeeq Mohamed112 reputationPosted Dec 7, 2011, 8:25 PM EST
I think you could do that using Process.GetProcessByNameif (pname.Length > 0)
MessageBox.Show("Running, do nothing");
else
MessageBox.Show("run again");
Naeem KhanRank #2,072 · 698 reputationPosted Dec 7, 2011, 11:00 PM EST
which event should be used for it...
VulpesRank #55 · 29.2K reputationPosted Dec 7, 2011, 11:39 PM EST
The best thing to do is to place Rafeeq's code at the top of your Main() method. If an instance of the application is already running, then you can display a message to the user and exit the second instance gracefully by returning immediately (with the 'return' statement) from the Main() method.
Sam HobbsRank #107 · 20.5K reputationPosted Dec 8, 2011, 6:47 AM EST
If the only thing you want to do is to determine if a previous instance exists, then there is a simple and reliable way to do that; you can use a Mutex. A Mutex is the most common solution for that.
There is sample code for a Mutex in Check running processes on a mobile device programmatically. I assume the reason it did not work for Nora is that (probably) Windows Mobile does not support use of Mutex like that; it should work for you.