As long as you want to check the computer on your own subnet, you can check it using ARP . Here is an example:
[DllImport("iphlpapi.dll", ExactSpelling = true)]
public static extern int SendARP(
int DestIP,
int SrcIP,
byte[] pMacAddr,
ref uint PhyAddrLen);
public bool IsComputerAlive(IPAddress host)
{
if (host.Equals(IPAddress.Loopback))
return true;
byte[] macAddr = new byte[6];
uint macAddrLen = (uint)macAddr.Length;
if (SendARP((int)host.Address, 0, macAddr, ref macAddrLen) == 0)
return true;
return false;
}
See Pinvoke.net for more details .
source
share