How to Detect Network Connection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Is there any way to detected if a device is connected? How would I query to
see the device is connected to network. My application is mobile and mostly
on wireless connection but it could be wired as well. Any Help would be
appreciated.
Regards
Al
 
http://www.vbip.com/wininet/wininet_connection_01.asp

OR

Imports System.Management

Public Function GetSignalStrength() As String
On Error Resume Next
Dim query As ManagementObjectSearcher
Dim Qc As ManagementObjectCollection
Dim Oq As ObjectQuery
Dim Ms As ManagementScope
Dim Co As ConnectionOptions
Dim Mo As ManagementObject
Dim outp As String
Co = New ConnectionOptions
Ms = New ManagementScope("root\wmi")
Oq = New ObjectQuery("SELECT * FROM MSNdis_80211_ReceivedSignalStrength
Where active=true")
query = New ManagementObjectSearcher(Ms, Oq)
Qc = query.Get
For Each Mo In query.Get
outp = outp & Mo("Ndis80211ReceivedSignalStrength") & " "
ISIPActive = Mo("Active")
Next
Return outp.Trim()
End Function

OR

http://msdn.microsoft.com/library/d.../en-us/wmisdk/wmi/win32_networkconnection.asp

Private Sub GetNetworkStatus()
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_NetworkConnection")

moReturn = moSearch.Get
For Each mo In moReturn
Dim strOut As String
strOut = String.Format("{0} - Status {1}", mo("Name").ToString,
mo("Status").ToString)
Trace.WriteLine(strOut)
Next
End Sub

Here is a link to see if you are connected to a network that uses a
ping

http://msdn.microsoft.com/library/d...ry/en-us/dndotnet/html/northwindunplugged.asp
 
Thank you so much

scorpion53061 said:
http://www.vbip.com/wininet/wininet_connection_01.asp

OR

Imports System.Management

Public Function GetSignalStrength() As String
On Error Resume Next
Dim query As ManagementObjectSearcher
Dim Qc As ManagementObjectCollection
Dim Oq As ObjectQuery
Dim Ms As ManagementScope
Dim Co As ConnectionOptions
Dim Mo As ManagementObject
Dim outp As String
Co = New ConnectionOptions
Ms = New ManagementScope("root\wmi")
Oq = New ObjectQuery("SELECT * FROM MSNdis_80211_ReceivedSignalStrength
Where active=true")
query = New ManagementObjectSearcher(Ms, Oq)
Qc = query.Get
For Each Mo In query.Get
outp = outp & Mo("Ndis80211ReceivedSignalStrength") & " "
ISIPActive = Mo("Active")
Next
Return outp.Trim()
End Function

OR

http://msdn.microsoft.com/library/d.../en-us/wmisdk/wmi/win32_networkconnection.asp

Private Sub GetNetworkStatus()
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_NetworkConnection")

moReturn = moSearch.Get
For Each mo In moReturn
Dim strOut As String
strOut = String.Format("{0} - Status {1}", mo("Name").ToString,
mo("Status").ToString)
Trace.WriteLine(strOut)
Next
End Sub

Here is a link to see if you are connected to a network that uses a
ping

http://msdn.microsoft.com/library/d...ry/en-us/dndotnet/html/northwindunplugged.asp
 
You might want to strip out that:
On Error Resume Next statement though. Ouch.

Steve
 
LOL

I forgot my perfection pills today.

Steve Long said:
You might want to strip out that:
On Error Resume Next statement though. Ouch.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top