첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ 실행 프로세스 여부를 구하는 방법을 보여준다.

 

▶ 예제 코드 (C#)

using System.Diagnostics;
using System.IO;
using System.Threading;

#region 실행 프로세스 여부 구하기 - IsRunningProcess(mutexName, processName)

/// <summary>
/// 실행 프로세스 여부 구하기
/// </summary>
/// <param name="mutexName">뮤텍스명</param>
/// <param name="processName">프로세스명</param>
/// <returns>실행 프로세스 여부</returns>
public bool IsRunningProcess(string mutexName, string processName)
{
    if(!string.IsNullOrWhiteSpace(mutexName))
    {
        using(Mutex mutex = new Mutex(false, mutexName, out bool createdNew))
        {
            return createdNew != true;
        }
    }

    if(!string.IsNullOrWhiteSpace(processName))
    {
        processName = Path.GetFileNameWithoutExtension(processName);

        return Process.GetProcessesByName(processName).Length > 0;
    }

    return false;
}

#endregion
728x90
그리드형(광고전용)
Posted by icodebroker
,