Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All,

I tried systeminformation.network, but its returning true in both the cases.

I unhooked my laptop from docking station and tried with detaching the network cable also, still it SystemInformation.Network returns TRUE.

 

I don't know what is wrong or may be its a bug.

 

Do let me know if anyone can think of something else.

  • 2 weeks later...
Posted

hey guys i'm completely new to .net but i remember in VB6 there was an api InternetGetConnectedState that did check for connection

:confused:

i don't even know if you still can use apis in .net

Posted

:)

 

Yes, it is very possible to determine the connection. Here is how..

 

 

Private Declare Function InternetGetConnectedState Lib "wininet" _

(ByRef dwflags as long, ByVal dwReserved as Long) as Long

 

'Define types of connections

Private Enum ConnectStates

Lan=&H2

Modem=&H1

Proxy=&H4

Offline=&H20

Configured=&H40

RasInstalled=&H10

End Num

 

Public Sub Main()

dim dwFlags as Long

Dim Connected as boolean = _

(InternetGetConnectedState(dwFlags,0&) <> 0 )

 

If Connected Then

Console.writeline("I'm connected to the internet.")

Console.write("Connection flags:")

 

Dim ConnectionType as ConnectStates

For each connectiontype In_

System.Enum.GetValues(GetType(ConnectStates))

If (ConnectionType And dwFlags) = ConnectionType Then

Console.write(" " & ConnectionType.tostring())

End If

Next

End If

 

Console.ReadLine()

End Sub

 

End Module

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...