using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Collections;
using System.Runtime.InteropServices;
namespace App
{
static class Program
{
[DllImport("USER32.DLL", CharSet = CharSet.Auto)]
private static extern int ShowWindow(
System.IntPtr hWnd,
int nCmdShow
);
[DllImport("USER32.DLL", CharSet = CharSet.Auto)]
private static extern bool SetForegroundWindow(
System.IntPtr hWnd
);
private const int SW_NORMAL = 1;
private static bool CheckExistProcess(string processName)
{
bool aRet = false;
System.Diagnostics.Process[] arrProcess
= System.Diagnostics.Process.GetProcessesByName(processName);
if (arrProcess.Length > 0) { aRet = true; }
if (aRet)
{
try
{
foreach (System.Diagnostics.Process hProcess in arrProcess)
{
ShowWindow(hProcess.MainWindowHandle, SW_NORMAL);
SetForegroundWindow(hProcess.MainWindowHandle);
break;
}
}
catch { }
}
return aRet;
}
}
}