Well, finally I have found something....
http://spaces.msn.com/members/dotnoted/PersonalSpace.aspx?_c01_blogpart=blogmgmt&_c=blogpart
private bool isMachineReachable(string hostName)
{
System.Net.IPHostEntry host = System.Net.Dns.GetHostByName(hostName);
string wqlTemplate = "SELECT StatusCode FROM Win32_PingStatus WHERE
Address
= '{0}'";
System.Management.ManagementObjectSearcher query = new
ManagementObjectSearcher();
query.Query = new ObjectQuery(String.Format(wqlTemplate,
host.AddressList[0]));
query.Scope = new ManagementScope("//localhost/root/cimv2");
ManagementObjectCollection pings = query.Get();
foreach(ManagementObject ping in pings)
{
if( Convert.ToInt32(ping.GetPropertyValue("StatusCode")) == 0)
return true;
}
return false;
}
If I have a problem with it....I will give youi my feedback on it...
Marc-André said:
I would like to find a simple way to test if a computer is online.
I found a lot of code on internet about using existing ping class...but
the
code was not looking really good. There must be a simple way to do that?
Thanks!