CBuckley Posted February 10, 2010 Share Posted February 10, 2010 Hello, I was just wondering if there was a way to check if a specific network interface was not connected on my computer and then use this to warn the user. Thanks, Chris DataHostDirect Linux VPS Specialists Link to comment Share on other sites More sharing options...
James Posted February 10, 2010 Share Posted February 10, 2010 Chris, My suggestion is to use the following: $ChecK_It = IsAlive() If StringInStr($ChecK_It, "Not Connected") OR StringInStr($ChecK_It, "OffLine") Then MsgBox(0, "", "") EndIf Func IsAlive() Ping('www.google.com',3000) $Internet_Connection_Modem = 0x1 $Internet_Connection_Lan = 0x2 $Internet_Connection_Proxy = 0x4 $Internet_Connection_Modem_Busy = 0x8 $Internet_Ras_Installed = 0x10 $Internet_Connection_Offline = 0x20 $Internet_Connection_Configured = 0x40 $Ret = DllCall ("WinInet.dll", "int", "InternetGetConnectedState", "int_ptr", 0, "int", 0) If $Ret[0] then ;check type of connection $Sx = "" If BitAND ($Ret[1], $Internet_Connection_Modem) Then $Sx = $Sx & "MODEM" & @LF If BitAND ($Ret[1], $Internet_Connection_Lan) Then $Sx = $Sx & "LAN" & @LF If BitAND ($Ret[1], $Internet_Connection_Proxy) Then $Sx = $Sx & "PROXY" & @LF If BitAND ($Ret[1], $Internet_Connection_Modem_Busy) Then $Sx = $Sx & "MODEM_BUSY" & @LF If BitAND ($Ret[1], $Internet_Ras_Installed) Then $Sx = $Sx & "RAS_INSTALLED" & @LF If BitAND ($Ret[1], $Internet_Connection_Offline) Then $Sx = $Sx & "OFFLINE" & @LF If BitAND ($Ret[1], $Internet_Connection_Configured) Then $Sx = $Sx & "CONFIGURED" & @LF Else $Sx = "Not Connected" Endif Return $Sx EndFunc ;<==> Is_Alive() However, if you have two or more network devices, this will require both of them to be disconnected. Perhaps turn WiFi off if you were to have it enabled. James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
CBuckley Posted February 10, 2010 Author Share Posted February 10, 2010 Yeah, I tried something similar but the problem being is that it really does need to be dependant on one of my NIC's rather than both. I thought maybe winsock but I haven't used winsock since winsock one and even then I wasn't too good at it. DataHostDirect Linux VPS Specialists Link to comment Share on other sites More sharing options...
James Posted February 11, 2010 Share Posted February 11, 2010 CBuckley, Could you not ping the device you're connecting to? James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now