Thursday, November 13, 2008

C#: Check if an application is already running

using System.Diagnostics;

bool IsApplicationAlreadyRunning()
{
string proc=Process.GetCurrentProcess().ProcessName;
Process[] processes=Process.GetProcessesByName(proc);
if (processes.Length > 1)
return true;
else
return false;
}

8 comments:

  1. Thank you very much - your code helped me on my way.

    ReplyDelete
  2. Where do i Insert the actual Name of the process, also how do i know the name? Is it a SetWindowTitle name?

    Thanks for the code mate ;D
    Cheers!

    ReplyDelete
  3. Hi KC
    Thanks a lot for the Code snippet. I was googling for last two hours but cant't find a simple and working snippet. your code give me a new idea. and i found my solution

    once again thanks
    Regards
    Jamal uddin

    ReplyDelete
  4. Thanks KC,
    good and simple solution

    ReplyDelete
  5. hi KC ....how to do same for compact framework?

    ReplyDelete

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.