When I trying to get the process name, it work well when the target process is running. But it turn out error with [ System.IndexOutOfRangeException ] if the target process was not running.
public Int32 GetProcessId(String proc)
{
Process[] ProcList;
ProcList = Process.GetProcessesByName(proc);
return ProcList[0].Id;
}
is the return error??