;-- TIME_STAMP 2017-09-03 20:35:21 v 1.0 ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetLocalIP ; Description ...: Besorgt die lokale IP-Adresse und den dazugehörigen Namen. ; Syntax ........: _GetLocalIP([$iReturnType = 1]) ; Parameters ....: $iReturnType - [optional] an integer value. Default is 1. ; Return values .: Success: $iReturnType = 1 - String: $sIP ; $iReturnType = 2 - Array: $aLocalIP[0] = IP, $aLocalIP[1] = Name, $aLocalIP[2] = Subnet, $aLocalIP[3] = Host-ID ; @extended >= 0 - Roundtrip-time in milliseconds (Greater than or equal to zero) ; @extended < 0 - -1 = Host is offline, -2 = Host is unreachable, -3 = Bad destination, -4 = Other errors ; Failure: - Bolean: False ; @error = 1 - $obj error - contact the author! ; @error = 2 - Parsing error (HostName not found) - contact the author! ; @error = 3 - $iReturnType is out of range! ; Author ........: Bitnugger ; Modified ......: ; Remarks .......: Die Makros @IPAddress1 - @IPAddress4 finden nur die ersten vier installierten Netzwerk-Adapter... ; Related .......: _GetIP(), TCPNameToIP, _TCPIpToName, _WinAPI_IsInternetConnected, Ping ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GetLocalIP($iReturnType = 1) Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2") Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems If $objItem.DNSHostName(0) = @ComputerName Then For $j = 0 To 256 Step 1 ;~ ConsoleWrite('$objItem.IPAddress('&$j&') = ' & $objItem.IPAddress($j) & @CRLF) Next If StringRight($objItem.IPAddress(0), 2) = '.1' Then ContinueLoop Local $iPing = Ping($objItem.IPAddress(0), 1000) $iPing = (@error > 0) ? - @error : $iPing Switch $iReturnType Case 1 Return SetExtended($iPing, $objItem.IPAddress(0)) Case 2 Local $aLocalIP[4] $aLocalIP[0] = $objItem.IPAddress(0) ; IP - "192.168.178.26" $aLocalIP[1] = StringUpper($objItem.DNSHostName(0)) ; Name - "ILLUMINATI" $aLocalIP[2] = StringRegExpReplace($aLocalIP[0], '(.+)(?:\.\d{1,3}$)', '\1.0') ; Subnet - "192.168.178.0" $aLocalIP[3] = StringRegExpReplace($aLocalIP[0], '(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3}$)', '\1') ; Host-ID - "26" Return SetExtended($iPing, $aLocalIP) Case Else Return SetError(3, 0, False) EndSwitch EndIf Next Return SetError(2, 0, False) Else SetError(1, 0, False) EndIf EndFunc ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #cs [Dynamic, Provider("CIMWin32"), UUID("{8502C515-5FBB-11D2-AAC1-006008C78BC7}"), AMENDMENT] class Win32_NetworkAdapterConfiguration : CIM_Setting { string Caption; string Description; string SettingID; boolean ArpAlwaysSourceRoute; boolean ArpUseEtherSNAP; string DatabasePath; boolean DeadGWDetectEnabled; string DefaultIPGateway[]; uint8 DefaultTOS; uint8 DefaultTTL; boolean DHCPEnabled; datetime DHCPLeaseExpires; datetime DHCPLeaseObtained; string DHCPServer; string DNSDomain; string DNSDomainSuffixSearchOrder[]; boolean DNSEnabledForWINSResolution; string DNSHostName; string DNSServerSearchOrder[]; boolean DomainDNSRegistrationEnabled; uint32 ForwardBufferMemory; boolean FullDNSRegistrationEnabled; uint16 GatewayCostMetric[]; uint8 IGMPLevel; uint32 Index; uint32 InterfaceIndex; string IPAddress[]; uint32 IPConnectionMetric; boolean IPEnabled; boolean IPFilterSecurityEnabled; boolean IPPortSecurityEnabled; string IPSecPermitIPProtocols[]; string IPSecPermitTCPPorts[]; string IPSecPermitUDPPorts[]; string IPSubnet[]; boolean IPUseZeroBroadcast; string IPXAddress; boolean IPXEnabled; uint32 IPXFrameType[]; uint32 IPXMediaType; string IPXNetworkNumber[]; string IPXVirtualNetNumber; uint32 KeepAliveInterval; uint32 KeepAliveTime; string MACAddress; uint32 MTU; uint32 NumForwardPackets; boolean PMTUBHDetectEnabled; boolean PMTUDiscoveryEnabled; string ServiceName; uint32 TcpipNetbiosOptions; uint32 TcpMaxConnectRetransmissions; uint32 TcpMaxDataRetransmissions; uint32 TcpNumConnections; boolean TcpUseRFC1122UrgentPointer; uint16 TcpWindowSize; boolean WINSEnableLMHostsLookup; string WINSHostLookupFile; string WINSPrimaryServer; string WINSScopeID; string WINSSecondaryServer; }; #ce