#include #include #include #include #include #include #Region ### START Koda GUI section ### Form= $fGUI = GUICreate("Adapters informations", 624, 520, 190, 131) $rIPv4 = GUICtrlCreateRadio("IPv4", 32, 32, 97, 33) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetState(-1, $GUI_CHECKED) $rIPv6 = GUICtrlCreateRadio("IPv6", 32, 56, 97, 33) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $rBoth = GUICtrlCreateRadio("Both", 32, 80, 97, 33) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $bShow = GUICtrlCreateButton("SHOW", 160, 56, 97, 49) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $chTunnel = GUICtrlCreateCheckbox("Show tunnel interfaces", 136, 16, 161, 25) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") Global $coAdapters = GUICtrlCreateCombo("", 328, 24, 257, 25, $CBS_DROPDOWNLIST) GUICtrlSetState(-1, $GUI_DISABLE) $gIptypes = GUICtrlCreateGroup("IP Type", 16, 8, 105, 113) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) $gIpt = GUICtrlCreateGroup("", 10, 140, 605, 365) GUICtrlCreateGroup("", -99, -99, 1, 1) $lAdapterName = GUICtrlCreateLabel("Adapter name:", 16, 155, 122, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lFriendlyName = GUICtrlCreateLabel("Friendly name:", 16, 179, 121, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lDescription = GUICtrlCreateLabel("Description:", 16, 203, 100, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lMAC = GUICtrlCreateLabel("MAC:", 16, 251, 47, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lType = GUICtrlCreateLabel("Type:", 16, 227, 47, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lUnicast = GUICtrlCreateLabel("Unicast address(es):", 16, 280, 170, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lAnycast = GUICtrlCreateLabel("Anycast address(es):", 16, 325, 173, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lMulticast = GUICtrlCreateLabel("Multicast address(es):", 16, 381, 181, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lDNS1 = GUICtrlCreateLabel("DNS server 1:", 16, 451, 115, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $lDNS2 = GUICtrlCreateLabel("DNS server 2:", 16, 475, 115, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $eUnicast = GUICtrlCreateEdit("", 192, 280, 297, 41, BitOR($WS_VSCROLL, $ES_READONLY)) Global $eAnycast = GUICtrlCreateEdit("", 192, 328, 297, 41, BitOR($WS_VSCROLL, $ES_READONLY)) Global $eMulticast = GUICtrlCreateEdit("", 192, 384, 297, 65, BitOR($WS_VSCROLL, $ES_READONLY)) Global $lAdapterNameText = GUICtrlCreateLabel("", 192, 160, 442, 17) Global $lFriendlyNameText = GUICtrlCreateLabel("", 192, 184, 426, 17) Global $lDescriptionText = GUICtrlCreateLabel("", 192, 208, 426, 17) Global $lTypeText = GUICtrlCreateLabel("", 192, 232, 426, 17) Global $lMACText = GUICtrlCreateLabel("", 192, 256, 426, 25) Global $lDNS1Text = GUICtrlCreateLabel("", 192, 456, 258, 17) Global $lDNS2Text = GUICtrlCreateLabel("", 192, 480, 258, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $bShow Local $sAdapters = "" If BitAND(GUICtrlGetState($coAdapters), $GUI_DISABLE) == $GUI_DISABLE Then GUICtrlSetState($coAdapters, $GUI_ENABLE) GUICtrlSetData($coAdapters, "", "") Select Case BitAND(GUICtrlRead($rIPv4), $GUI_CHECKED) == $GUI_CHECKED $Family = 2 Case BitAND(GUICtrlRead($rIPv6), $GUI_CHECKED) == $GUI_CHECKED $Family = 23 Case BitAND(GUICtrlRead($rBoth), $GUI_CHECKED) == $GUI_CHECKED $Family = 0 EndSelect If BitAND(GUICtrlRead($chTunnel), $GUI_CHECKED) == $GUI_CHECKED Then $Tunnel = 1 Else $Tunnel = 0 EndIf Local $aAdapters = _WinAPI_GetAdaptersAddresses($Family, 2, $Tunnel) If @error == 5 Then MsgBox(16, "ERROR", "Your system doesn't support IPv6") GUICtrlSetState($coAdapters, $GUI_DISABLE) GUICtrlSetState($rIPv6, $GUI_DISABLE) GUICtrlSetState($rIPv4, $GUI_CHECKED) ElseIf @error Then MsgBox(16, "ERROR", "@error = " & @error) Exit Else For $i = 0 To UBound($aAdapters) - 1 $sAdapters &= StringReplace($aAdapters[$i][7], "|", "/") & "|" Next GUICtrlSetData($coAdapters, StringTrimRight($sAdapters, 1), $aAdapters[0][7]) _setData($aAdapters) EndIf Case $coAdapters _setData($aAdapters) EndSwitch WEnd Func _setData($array) For $i = 0 To UBound($array) - 1 If StringReplace($array[$i][7], "|", "/") == GUICtrlRead($coAdapters) Then ExitLoop Next GUICtrlSetData($lAdapterNameText, $array[$i][6]) GUICtrlSetData($lFriendlyNameText, $array[$i][1]) GUICtrlSetData($lDescriptionText, $array[$i][7]) GUICtrlSetData($lTypeText, $array[$i][9]) GUICtrlSetData($lMACText, $array[$i][8]) GUICtrlSetData($lDNS1Text, $array[$i][4]) GUICtrlSetData($lDNS2Text, $array[$i][5]) If IsArray($array[$i][0]) Then Local $aTemp = $array[$i][0], $sAddresses = "" For $j = 0 To UBound($aTemp) - 1 If $j <> (UBound($aTemp) - 1) Then $sAddresses &= $aTemp[$j] & @CRLF Else $sAddresses &= $aTemp[$j] EndIf Next GUICtrlSetData($eUnicast, $sAddresses) Else GUICtrlSetData($eUnicast, $array[$i][0]) EndIf Local $aTemp = $array[$i][2], $sAddresses = "" For $j = 0 To UBound($aTemp) - 1 If $j <> (UBound($aTemp) - 1) Then $sAddresses &= $aTemp[$j] & @CRLF Else $sAddresses &= $aTemp[$j] EndIf Next GUICtrlSetData($eAnycast, $sAddresses) Local $aTemp = $array[$i][3], $sAddresses = "" For $j = 0 To UBound($aTemp) - 1 If $j <> (UBound($aTemp) - 1) Then $sAddresses &= $aTemp[$j] & @CRLF Else $sAddresses &= $aTemp[$j] EndIf Next GUICtrlSetData($eMulticast, $sAddresses) EndFunc ;==>_setData ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetAdaptersAddresses ; Description ...: Retrieves the addresses associated with the adapters on the local computer. ; Syntax.........: _WinAPI_GetAdaptersAddresses($iFamily = 2, $iShowAll = 1, $iShowTunnel = 0) ; Parameters ....: $iFamily - IP type. ; |0 - Both ; |2 - IPv4 (default) ; |23 - IPv6 ; $iShowAll - Presentation mode ; |0 - Short: only Unicast address(es) and Friendly Name columns are returned ; |1 - Long (default): all columns are returned but Anycast and Multicast columns return only the first address (it is not an array) ; |2 - Complete: all columns are returned, Anycast and Multicast columns return an array with the complete list of addresses ; $iShowTunnel - Shows or not tunnel interfaces ; |0 - Don't show (default) ; |1 - Show ; Return values .: On success it returns a bidimensional array: on rows there is the adapter list, these are the columns ; |0 - Preferred unicast address(es), it returns an array of addresses only if $iFamily == 0 ; |1 - Friendly name ; |2 - Anycast addresses: if $iShowAll == 1 it returns the first anycast address of the list, ; if $iShowAll == 2 it returns an array with the complete list of anycast addresses ; |3 - Multicast addresses: if $iShowAll == 1 it returns the first multicast address of the list, ; if $iShowAll == 2 it returns an array with the complete list of multicast addresses ; |4 - DNS Server 1 address ; |5 - DNS Server 2 address ; |6 - Adapter Name ; |7 - Description ; |8 - MAC address ; |9 - Interface Type ; for example $array[2][8] represents the MAC address of the third adapter ; ; On failure it returns 0 and sets @error to non zero (these values are useful only for debugging reasons): ; |1 - incorrect parameters ; |2 - DllOpen error ; |3 - DllCall error ; |4 - _WinAPI_GetString error ; |5 - Query for IPv6 addresses and IPv6 is not installed on the OS ; Author ........: j0kky ; Modified ......: 1.1.3 13/02/15 ; Remarks .......: This function is fully compatible with all OS from Windows XP onwards, there can be some problem using this function ; with $iFamily == 23 if the OS is prior to Windows XP SP1 ; Link ..........: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365915(v=vs.85).aspx ; =============================================================================================================================== #include Func _WinAPI_GetAdaptersAddresses($iFamily = 2, $iShowAll = 1, $iShowTunnel = 0) If Not ($iFamily == 0 Or $iFamily == 2 Or $iFamily == 23) Or _ Not ($iShowAll == 0 Or $iShowAll == 1 Or $iShowAll == 2) Or _ Not ($iShowTunnel == 0 Or $iShowTunnel == 1) Then Return SetError(1, 0, 0) Local $aRet If $iFamily == 23 Then $aRet = DllCall("Ws2_32.dll", "int", "WSCEnumProtocols", "ptr", Null, "ptr", Null, "dword*", Null, "ptr", Null) Local $tlpProtocolBuffer = DllStructCreate("byte[" & $aRet[3] & "]") Local $plpProtocolBuffer = DllStructGetPtr($tlpProtocolBuffer) $aRet = DllCall("Ws2_32.dll", "int", "WSCEnumProtocols", "ptr", Null, "ptr", $plpProtocolBuffer, "dword*", $aRet[3], "ptr", Null) Local $tagWSAPROTOCOL_INFOW = "dword dwServiceFlags1; dword dwServiceFlags2; dword dwServiceFlags3; dword dwServiceFlags4; dword dwServiceFlags5; byte ProviderId[16]; " & _ "dword dwCatalogEntryId; " & _ "STRUCT; int ChainLen; dword ChainEntries[7]; ENDSTRUCT;" & _ ;ProtocolChain "int iVersion; int iAddressFamily; int iMaxSockAddr; int iMinSockAddr; int iSocketType; int iProtocol; int iProtocolMaxOffset; int iNetworkByteOrder; " & _ "int iSecurityScheme; dword dwMessageSize; dword dwProviderReserved; wchar szProtocol[256]" Local $tWSAPROTOCOL_INFOW, $size For $i = 0 To $aRet[0] - 1 If $i == 0 Then $tWSAPROTOCOL_INFOW = DllStructCreate($tagWSAPROTOCOL_INFOW, $plpProtocolBuffer) Else $tWSAPROTOCOL_INFOW = DllStructCreate($tagWSAPROTOCOL_INFOW, $plpProtocolBuffer + $size) EndIf If DllStructGetData($tWSAPROTOCOL_INFOW, "iAddressFamily") == 23 Then ExitLoop If $i == ($aRet[0] - 1) Then Return SetError(5, 0, 0) ;if IPv6 is not installed on the system $size += DllStructGetSize($tWSAPROTOCOL_INFOW) Next EndIf $hIphlpapi = DllOpen("Iphlpapi.dll") If @error Then Return SetError(2, 0, 0) $aRet = DllCall($hIphlpapi, "ULONG", "GetAdaptersAddresses", "ULONG", $iFamily, "ULONG", 0, "ptr", Null, "ptr", Null, "dword*", 0) If @error Then DllClose($hIphlpapi) Return SetError(3, 0, 0) EndIf Local $tbuffer_AdapterAddresses = DllStructCreate("byte[" & $aRet[5] & "]") Local $pbuffer_AdapterAddresses = DllStructGetPtr($tbuffer_AdapterAddresses) DllCall($hIphlpapi, "ULONG", "GetAdaptersAddresses", "ULONG", $iFamily, "ULONG", 0, "ptr", Null, "ptr", $pbuffer_AdapterAddresses, "dword*", $aRet[5]) If @error Then DllClose($hIphlpapi) Return SetError(3, 0, 0) EndIf DllClose($hIphlpapi) Local Const $tagIP_ADAPTER_ADDRESSES = "ulong Length; dword IfIndex; ptr Next; ptr AdapterName; ptr FirstUnicastAddress; ptr FirstAnycastAddress; " & _ "ptr FirstMulticastAddress; ptr FirstDnsServerAddress; ptr DnsSuffix; ptr Description; ptr FriendlyName; byte PhysicalAddress[8]; dword PhysicalAddressLength; " & _ "dword Flags; dword Mtu; dword IfType; int OperStatus" ;valid on Windows XP #cs "dword Ipv6IfIndex; dword ZoneIndices[16]; ptr FirstPrefix; " & _ ;added on WinXP SP1 "uint64 TransmitLinkSpeed; uint64 ReceiveLinkSpeed; ptr FirstWinsServerAddress; ptr FirstGatewayAddress; ulong Ipv4Metric; ulong Ipv6Metric; uint64 Luid; " & _ "STRUCT; ptr Dhcpv4ServerlpSockaddr; int Dhcpv4ServeriSockaddrLength; ENDSTRUCT; " & _ ;Dhcpv4Server "uint CompartmentId; byte NetworkGuid[16]; int ConnectionType; int TunnelType; " & _ "STRUCT; ptr Dhcpv6ServerlpSockaddr; int Dhcpv6ServeriSockaddrLength; ENDSTRUCT; " & _ ;Dhcpv6Server "byte Dhcpv6ClientDuid[130]; ulong Dhcpv6ClientDuidLength; ulong Dhcpv6Iaid; " & _ ;added on WinVista "ptr FirstDnsSuffix" ;added on WinVista SP1 #ce Local Const $tagIP_ADAPTER_UNICAST_ADDRESS = "ulong Length; dword Flags; ptr Next; " & _ "STRUCT; ptr AddresslpSockaddr; int AddressiSockaddrLength; ENDSTRUCT; " & _ ;Address "int PrefixOrigin; int SuffixOrigin; int DadState; ulong ValidLifetime; ulong PreferredLifetime; ulong LeaseLifetime" #cs "byte OnLinkPrefixLength" ;added on WinVista #ce Local $tIP_ADAPTER_ADDRESSES = DllStructCreate($tagIP_ADAPTER_ADDRESSES, $pbuffer_AdapterAddresses) Local $nAdapter = 0, $pUnicastAddress, $tIP_ADAPTER_UNICAST_ADDRESS, $plpSockaddr, $iSockaddrLength, $tbuffer_lpszAddressString, $pbuffer_lpszAddressString Local Const $IfOperStatusUp = 1, $IF_TYPE_SOFTWARE_LOOPBACK = 24, $IF_TYPE_TUNNEL = 131, $IpDadStatePreferred = 4, $pNull = Ptr(0) If $iShowAll Then Local $nColumns = 10 Local Const $tagIP_ADAPTER_ANYCAST_ADDRESS = "ulong Length; dword Flags; ptr Next; " & _ "STRUCT; ptr AddresslpSockaddr; int AddressiSockaddrLength; ENDSTRUCT" ;Address Local Const $tagIP_ADAPTER_MULTICAST_ADDRESS = $tagIP_ADAPTER_ANYCAST_ADDRESS Local Const $tagIP_ADAPTER_DNS_SERVER_ADDRESS = "ulong Length; dword Reserved; ptr Next; " & _ "STRUCT; ptr AddresslpSockaddr; int AddressiSockaddrLength; ENDSTRUCT" ;Address Local $pAnycastAddress, $tIP_ADAPTER_ANYCAST_ADDRESS, $pMulticastAddress, $tIP_ADAPTER_MULTICAST_ADDRESS, $pDnsServerAddress, $tADAPTER_DNS_SERVER_ADDRESS, $sMAC Local Const $IF_TYPE_ETHERNET_CSMACD = 6, $IF_TYPE_IEEE80211 = 71, $IF_TYPE_IEEE1394 = 144 Else Local $nColumns = 2 EndIf Local $aResult[$nAdapter][$nColumns] $hWs2_32 = DllOpen("Ws2_32.dll") If @error Then Return SetError(2, 0, 0) TCPStartup() Do If DllStructGetData($tIP_ADAPTER_ADDRESSES, "OperStatus") == $IfOperStatusUp And _ Not (DllStructGetData($tIP_ADAPTER_ADDRESSES, "IfType") == $IF_TYPE_SOFTWARE_LOOPBACK) And _ (Not (DllStructGetData($tIP_ADAPTER_ADDRESSES, "IfType") == $IF_TYPE_TUNNEL) Or $iShowTunnel) Then ;if it's connected and it is not a loopback and it is a tunnel interface (only if $iShowTunnel == 1) $nAdapter += 1 ReDim $aResult[$nAdapter][$nColumns] ;Unicast address(es) $pUnicastAddress = DllStructGetData($tIP_ADAPTER_ADDRESSES, "FirstUnicastAddress") $tIP_ADAPTER_UNICAST_ADDRESS = DllStructCreate($tagIP_ADAPTER_UNICAST_ADDRESS, $pUnicastAddress) If Not $iFamily Then Local $aAddresses[0], $iCounter = -1 Do ;write the PREFERRED address for this adapter, it writes both IPV4 and IPV6 preferred addresses in an array if $iFamily == 0 If DllStructGetData($tIP_ADAPTER_UNICAST_ADDRESS, "DadState") == $IpDadStatePreferred Then $plpSockaddr = DllStructGetData($tIP_ADAPTER_UNICAST_ADDRESS, "AddresslpSockaddr") $iSockaddrLength = DllStructGetData($tIP_ADAPTER_UNICAST_ADDRESS, "AddressiSockaddrLength") $aRet = DllCall($hWs2_32, "int", "WSAAddressToString", "ptr", $plpSockaddr, "int", $iSockaddrLength, "ptr", Null, "byte*", Null, "dword*", 0) If @error Then DllClose($hWs2_32) Return SetError(3, 0, 0) EndIf $tbuffer_lpszAddressString = DllStructCreate("wchar[" & $aRet[5] & "]") $pbuffer_lpszAddressString = DllStructGetPtr($tbuffer_lpszAddressString) $aRet = DllCall($hWs2_32, "int", "WSAAddressToStringW", "ptr", $plpSockaddr, "int", $iSockaddrLength, "ptr", Null, "ptr", $pbuffer_lpszAddressString, "dword*", $aRet[5]) If @error Then DllClose($hWs2_32) Return SetError(3, 0, 0) EndIf If $iFamily Then $aResult[$nAdapter - 1][0] = _WinAPI_GetString($pbuffer_lpszAddressString) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf ExitLoop Else $iCounter = UBound($aAddresses) ReDim $aAddresses[$iCounter + 1] $aAddresses[$iCounter] = _WinAPI_GetString($pbuffer_lpszAddressString) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf EndIf EndIf $pUnicastAddress = DllStructGetData($tIP_ADAPTER_UNICAST_ADDRESS, "Next") If Not ($pUnicastAddress == $pNull) Then $tIP_ADAPTER_UNICAST_ADDRESS = DllStructCreate($tagIP_ADAPTER_UNICAST_ADDRESS, $pUnicastAddress) EndIf Until $pUnicastAddress == $pNull If Not $iFamily Then If $iCounter < 0 Then ReDim $aAddresses[1] ;if there is no preferred unicast addresses for this adapter, I don't know if it can happens $aResult[$nAdapter - 1][0] = $aAddresses EndIf ;FriendlyName $aResult[$nAdapter - 1][1] = _WinAPI_GetString(DllStructGetData($tIP_ADAPTER_ADDRESSES, "FriendlyName")) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf If $iShowAll Then ;Anycast address, it shows only the first one if $iShowAll == 1 $pAnycastAddress = DllStructGetData($tIP_ADAPTER_ADDRESSES, "FirstAnycastAddress") If Not ($pAnycastAddress == $pNull) Then $tIP_ADAPTER_ANYCAST_ADDRESS = DllStructCreate($tagIP_ADAPTER_ANYCAST_ADDRESS, $pAnycastAddress) If $iShowAll == 2 Then Local $aAddresses[0] While $pMulticastAddress <> $pNull $plpSockaddr = DllStructGetData($tIP_ADAPTER_ANYCAST_ADDRESS, "AddresslpSockaddr") $iSockaddrLength = DllStructGetData($tIP_ADAPTER_ANYCAST_ADDRESS, "AddressiSockaddrLength") $aRet = DllCall($hWs2_32, "int", "WSAAddressToString", "ptr", $plpSockaddr, "int", $iSockaddrLength, "ptr", Null, "byte*", Null, "dword*", 0) If @error Then DllClose($hWs2_32) Return SetError(3, 0, 0) EndIf $tbuffer_lpszAddressString = DllStructCreate("wchar[" & $aRet[5] & "]") $pbuffer_lpszAddressString = DllStructGetPtr($tbuffer_lpszAddressString) $aRet = DllCall($hWs2_32, "int", "WSAAddressToStringW", "ptr", $plpSockaddr, "int", $iSockaddrLength, "ptr", Null, "ptr", $pbuffer_lpszAddressString, "dword*", $aRet[5]) If @error Then DllClose($hWs2_32) Return SetError(3, 0, 0) EndIf If $iShowAll == 2 Then $iCounter = UBound($aAddresses) ReDim $aAddresses[$iCounter + 1] $aAddresses[$iCounter] = _WinAPI_GetString($pbuffer_lpszAddressString) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf Else $aResult[$nAdapter - 1][2] = _WinAPI_GetString($pbuffer_lpszAddressString) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf ExitLoop EndIf $pAnycastAddress = DllStructGetData($tIP_ADAPTER_ANYCAST_ADDRESS, "Next") If Not ($pAnycastAddress == $pNull) Then $tIP_ADAPTER_ANYCAST_ADDRESS = DllStructCreate($tagIP_ADAPTER_ANYCAST_ADDRESS, $pAnycastAddress) EndIf WEnd If $iShowAll == 2 Then If $aAddresses[0] Then $aResult[$nAdapter - 1][2] = $aAddresses EndIf EndIf ;Multicast address, it shows only the first one if $iShowAll == 1 $pMulticastAddress = DllStructGetData($tIP_ADAPTER_ADDRESSES, "FirstMulticastAddress") If Not ($pMulticastAddress == $pNull) Then $tIP_ADAPTER_MULTICAST_ADDRESS = DllStructCreate($tagIP_ADAPTER_MULTICAST_ADDRESS, $pMulticastAddress) If $iShowAll == 2 Then Local $aAddresses[0] While $pMulticastAddress <> $pNull $plpSockaddr = DllStructGetData($tIP_ADAPTER_MULTICAST_ADDRESS, "AddresslpSockaddr") $iSockaddrLength = DllStructGetData($tIP_ADAPTER_MULTICAST_ADDRESS, "AddressiSockaddrLength") $aRet = DllCall($hWs2_32, "int", "WSAAddressToString", "ptr", $plpSockaddr, "int", $iSockaddrLength, "ptr", Null, "byte*", Null, "dword*", 0) If @error Then DllClose($hWs2_32) Return SetError(3, 0, 0) EndIf $tbuffer_lpszAddressString = DllStructCreate("wchar[" & $aRet[5] & "]") $pbuffer_lpszAddressString = DllStructGetPtr($tbuffer_lpszAddressString) $aRet = DllCall($hWs2_32, "int", "WSAAddressToStringW", "ptr", $plpSockaddr, "int", $iSockaddrLength, "ptr", Null, "ptr", $pbuffer_lpszAddressString, "dword*", $aRet[5]) If @error Then DllClose($hWs2_32) Return SetError(3, 0, 0) EndIf If $iShowAll == 2 Then $iCounter = UBound($aAddresses) ReDim $aAddresses[$iCounter + 1] $aAddresses[$iCounter] = _WinAPI_GetString($pbuffer_lpszAddressString) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf Else $aResult[$nAdapter - 1][3] = _WinAPI_GetString($pbuffer_lpszAddressString) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf ExitLoop EndIf $pMulticastAddress = DllStructGetData($tIP_ADAPTER_MULTICAST_ADDRESS, "Next") If Not ($pMulticastAddress == $pNull) Then $tIP_ADAPTER_MULTICAST_ADDRESS = DllStructCreate($tagIP_ADAPTER_MULTICAST_ADDRESS, $pMulticastAddress) EndIf WEnd If $iShowAll == 2 Then If $aAddresses[0] Then $aResult[$nAdapter - 1][3] = $aAddresses EndIf EndIf ;DnsServer 1 and 2 $pDnsServerAddress = DllStructGetData($tIP_ADAPTER_ADDRESSES, "FirstDnsServerAddress") If Not ($pDnsServerAddress == $pNull) Then $tADAPTER_DNS_SERVER_ADDRESS = DllStructCreate($tagIP_ADAPTER_DNS_SERVER_ADDRESS, $pDnsServerAddress) For $iCounter = 4 To 5 $plpSockaddr = DllStructGetData($tADAPTER_DNS_SERVER_ADDRESS, "AddresslpSockaddr") $iSockaddrLength = DllStructGetData($tADAPTER_DNS_SERVER_ADDRESS, "AddressiSockaddrLength") $aRet = DllCall($hWs2_32, "int", "WSAAddressToString", "ptr", $plpSockaddr, "int", $iSockaddrLength, "ptr", Null, "byte*", Null, "dword*", 0) If @error Then DllClose($hWs2_32) Return SetError(3, 0, 0) EndIf $tbuffer_lpszAddressString = DllStructCreate("wchar[" & $aRet[5] & "]") $pbuffer_lpszAddressString = DllStructGetPtr($tbuffer_lpszAddressString) $aRet = DllCall($hWs2_32, "int", "WSAAddressToStringW", "ptr", $plpSockaddr, "int", $iSockaddrLength, "ptr", Null, "ptr", $pbuffer_lpszAddressString, "dword*", $aRet[5]) If @error Then DllClose($hWs2_32) Return SetError(3, 0, 0) EndIf $aResult[$nAdapter - 1][$iCounter] = _WinAPI_GetString($pbuffer_lpszAddressString) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf $pDnsServerAddress = DllStructGetData($tADAPTER_DNS_SERVER_ADDRESS, "Next") If Not ($pDnsServerAddress == $pNull) Then $tADAPTER_DNS_SERVER_ADDRESS = DllStructCreate($tagIP_ADAPTER_DNS_SERVER_ADDRESS, $pDnsServerAddress) Else ExitLoop EndIf Next EndIf ;AdapterName $aResult[$nAdapter - 1][6] = _WinAPI_GetString(DllStructGetData($tIP_ADAPTER_ADDRESSES, "AdapterName"), False) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf ;Description $aResult[$nAdapter - 1][7] = _WinAPI_GetString(DllStructGetData($tIP_ADAPTER_ADDRESSES, "Description")) If @error And @error <> 10 Then DllClose($hWs2_32) Return SetError(4, 0, 0) EndIf ;MAC $sMAC = String(DllStructGetData($tIP_ADAPTER_ADDRESSES, "PhysicalAddress")) $aResult[$nAdapter - 1][8] = StringRegExpReplace( _ StringTrimRight(StringTrimLeft($sMAC, 2), _ ;0x StringLen($sMAC) - ((DllStructGetData($tIP_ADAPTER_ADDRESSES, "PhysicalAddressLength") * 2) + 2)), _ "(.{2})(?!$)", "$1-") ;from 0xG4V4B5B4V2N2000000 to G4-V4-B5-B4-V2-N2 ;IfType Switch DllStructGetData($tIP_ADAPTER_ADDRESSES, "IfType") Case $IF_TYPE_ETHERNET_CSMACD Switch @OSVersion Case "WIN_XP", "WIN_XPe", "WIN_2003" $aResult[$nAdapter - 1][9] = "Ethernet or wireless network interface" Case Else $aResult[$nAdapter - 1][9] = "Ethernet network interface" EndSwitch Case $IF_TYPE_IEEE80211 $aResult[$nAdapter - 1][9] = "Wireless network interface" Case $IF_TYPE_TUNNEL $aResult[$nAdapter - 1][9] = "Tunnel type encapsulation network interface" Case $IF_TYPE_IEEE1394 $aResult[$nAdapter - 1][9] = "Firewire network interface" Case Else $aResult[$nAdapter - 1][9] = "Other type of network interface" EndSwitch EndIf EndIf $pbuffer_AdapterAddresses = DllStructGetData($tIP_ADAPTER_ADDRESSES, "Next") If Not ($pbuffer_AdapterAddresses == $pNull) Then $tIP_ADAPTER_ADDRESSES = DllStructCreate($tagIP_ADAPTER_ADDRESSES, $pbuffer_AdapterAddresses) EndIf Until $pbuffer_AdapterAddresses == $pNull TCPShutdown() DllClose($hWs2_32) Return $aResult EndFunc ;==>_WinAPI_GetAdaptersAddresses