Detect network connection

  • Thread starter Thread starter Merlin
  • Start date Start date
M

Merlin

Hi,

Is there a code snippet or suggestion on how I might detect whether a
computer is connected to a internal network??

Thanks,
Merlin
 
Hi Merlin,

I did try to answer you, but could not find a snippet and forgot to send my
answer..

Using Ping to the central server is the most easy way, I could only not find
a simple piece of code to do that ping, maybe you can Google for that.

Cor
 
I did it the following way

private bool CheckNetwork(

System.Net.IPHostEntry hostInfo
tr

// You can replace the following 2 lines if you can use a fixed servernam
string sServer = Environment.GetEnvironmentVariable("logonserver")
sServer = sServer.Remove(0, 2); //Remove leading "\\" because I only need the servernam
hostInfo = System.Net.Dns.GetHostByName(sServer)
return true;

catc

return false
 
Back
Top