Search the Community
Showing results for tags 'conection'.
-
I was needing to check all my connected networks and check if there is internet connection. so I wrote this function. #include <MsgBoxConstants.au3> #include <Array.au3> Global $NLM_ENUM_NETWORK_CONNECTED = 0x01 ;~ Global $NLM_ENUM_NETWORK_DISCONNECTED = 0x02 ;~ Global $NLM_ENUM_NETWORK_ALL = 0x03 Global Enum $eName, $eIsConectedtoInternet Local $aNetworks = GetNetWorks() If @extended Then For $i = 0 To @extended - 1 ConsoleWrite("NetWork Name: " & $aNetworks[$i][$eName] & "| IsConectedToInternet: " & $aNetworks[$i][$eIsConectedtoInternet] & @CRLF) Next _ArrayDisplay($aNetworks, "NetWork Name|NetWork Is Conected to Internet") EndIf ;~ Success: Return an 2DArray[][] and sets @extended Ubound of Array ;~ Failure: Return 0 and set @extended 0 Func GetNetWorks($NLM_ENUM_NETWORK = $NLM_ENUM_NETWORK_CONNECTED) Local $aNetworks[0][2] ;[n][0]NetWorks Name|[n][1]isConnectedtoInternet Local $INetworks = 0 Local $ReDim = 0 Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oINetworkListManager = ObjCreate("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}") ;Create INetworkListManager Object by CLSID If Not IsObj($oINetworkListManager) Then Return 0 $INetworks = $oINetworkListManager.GetNetworks($NLM_ENUM_NETWORK) If Not IsObj($INetworks) Then Return 0 For $INetwork In $INetworks $ReDim = UBound($aNetworks, 1) + 1 ReDim $aNetworks[$ReDim][2] $aNetworks[$ReDim - 1][0] = $INetwork.GetName $aNetworks[$ReDim - 1][1] = $INetwork.isConnectedtoInternet Next $oINetworkListManager = 0 ;Free Return SetExtended($ReDim, $aNetworks) EndFunc ;==>GetNetWorks ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Saludos