//cx为要判断的进程名的字符串数组
int i = 0;
string aa="";
System.Net.IPAddress[] _IPList = System.Net.Dns.GetHostAddresses(Dns.GetHostName());
for (int j = 0; j != _IPList.Length; j++)
{
if (_IPList[j].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
aa=_IPList[j].ToString()+"||";
}
}
string ss = "computername:" + Dns.GetHostName() + "\rIP:" + aa + "\r";
Process[] arrayProcess = Process.GetProcesses();
Process[] ppp;
foreach(string pn in cx){
// MessageBox.Show(pn);
ppp = Process.GetProcessesByName(pn);
if (ppp.Length <= 0)
{
i = 1;
ss += con(pn) + " process is not running" + "\r";
}
}
foreach (Process process in arrayProcess)
{
if(Array.Exists(cx, element => element == process.ProcessName))
{
//MessageBox.Show(process.ProcessName);
if (process.Responding == false)
{
i = 1;
ss += con(process.ProcessName) + " process wrong" + "\r";
}
}
}
if (i == 0) {
ss += "all of processes are normal";
}
return ss;