vinidel Posted March 16, 2004 Posted March 16, 2004 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. Quote
*Gurus* Derek Stone Posted March 17, 2004 *Gurus* Posted March 17, 2004 There isn't a "correct" method. There's no way for an OS to determine conditions beyond the NIC or modem. Try connecting to a resource. If the connection completes you're connected. If it doesn't... well... there isn't a usable connection. Quote Posting Guidelines
morsnowski Posted March 25, 2004 Posted March 25, 2004 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 Quote
JoeEk Posted March 31, 2004 Posted March 31, 2004 :) 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.