System.Windows.Forms.SystemInformation
-
Ok, maybe I am dumb here but I am trying to detect if my computer is connected to the network. I spend about 15 minutes going through the docs and I find the System.Windows.Forms.SystemInformation class with Network property. Seems all too easy... I do the following:
Dim NetInfo As System.Windows.Forms.SystemInformation If NetInfo.Network = True Then pnlIndicator.BackColor = Color.Green Else pnlIndicator.BackColor = Color.Red End If
...and I figure, heay great, I should get a green panel when I have my net cable plugged in and it should go read when my cable gets unplugged (I placed this code into a timer tic event hander). NOPE. Does not seem to do anything... Anyone have any darn ideas? -
Ok, maybe I am dumb here but I am trying to detect if my computer is connected to the network. I spend about 15 minutes going through the docs and I find the System.Windows.Forms.SystemInformation class with Network property. Seems all too easy... I do the following:
Dim NetInfo As System.Windows.Forms.SystemInformation If NetInfo.Network = True Then pnlIndicator.BackColor = Color.Green Else pnlIndicator.BackColor = Color.Red End If
...and I figure, heay great, I should get a green panel when I have my net cable plugged in and it should go read when my cable gets unplugged (I placed this code into a timer tic event hander). NOPE. Does not seem to do anything... Anyone have any darn ideas?Mine seems to come up with "true" regardless of the reality as well. Maybe it means "if there's a network card" or "if there's something plugged into the network card, regardless of where it might go"? By the way, this function is static, you could just use:
' Dim removed If SystemInformation.Network Then pnlIndicator.BackColor = Color.Green Else pnlIndicator.BackColor = Color.Red End If
Won't solve your problem though. :rolleyes: Paul -
Mine seems to come up with "true" regardless of the reality as well. Maybe it means "if there's a network card" or "if there's something plugged into the network card, regardless of where it might go"? By the way, this function is static, you could just use:
' Dim removed If SystemInformation.Network Then pnlIndicator.BackColor = Color.Green Else pnlIndicator.BackColor = Color.Red End If
Won't solve your problem though. :rolleyes: PaulYeah, looks like it just says 'why yes, you do have a nic' :|
-
Yeah, looks like it just says 'why yes, you do have a nic' :|
Just reply "Well duh, I fitted it, you think I don't know it's there? Now is it connected to anything???" :-D;):-D
-
Yeah, looks like it just says 'why yes, you do have a nic' :|
Actually, what it means is that you have "Networking" installed. Whether it's DHCP, NetBios, etc it will still show true. If you uninstall your Networking protocols, it should return false. I forget where I saw it but there is a way to detect the Network.