2009년 1월 31일 토요일

프로그램 중복 실행 방지

== 프로젝트의 Program.cs 파일에 아래 내용 추가 ==


using System.Threading;
...
...

 static void Main()
{
    ...
    bool createdNew;
    Mutex dup = new Mutex(true, "Mutex text", out createdNew);
    if(createdNew)
    {
        Applictation.Run(new Form());
        dup.ReleaseMutex();
    }
    else
    {
        MessageBox.Show("이미 프로그램이 실행중 입니다.");
    }
}

댓글 없음:

댓글 쓰기