Well, finally I have found something....
http://spaces.msn.com/members/dotnot...mt&_c=blogpart
private bool isMachineReacha ble(string hostName)
{
System.Net.IPHo stEntry host = System.Net.Dns. GetHostByName(h ostName);
string wqlTemplate = "SELECT StatusCode FROM Win32_PingStatu s WHERE Address
= '{0}'";
System.Manageme nt.ManagementOb jectSearcher query = new
ManagementObjec tSearcher();
query.Query = new ObjectQuery(Str ing.Format(wqlT emplate,
host.AddressLis t[0]));
query.Scope = new ManagementScope ("//localhost/root/cimv2");
ManagementObjec tCollection pings = query.Get();
foreach(Managem entObject ping in pings)
{
if( Convert.ToInt32 (ping.GetProper tyValue("Status Code")) == 0)
return true;
}
return false;
}
If I have a problem with it....I will give youi my feedback on it...
"Marc-André" wrote:
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!