Popular Post Danyfirex Posted July 24, 2015 Popular Post Share Posted July 24, 2015 I was needing to check all my connected networks and check if there is internet connection. so I wrote this function. expandcollapse popup#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 ;==>_ErrFuncSaludos JohnOne, argumentum, trancexx and 3 others 6 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
232showtime Posted July 25, 2015 Share Posted July 25, 2015 this is great, thanks for sharing... ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. 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