Hi, Ich schreibe mir gerade ein kleines Ping-Subnet programm (Es scannt einen ip stamm nach rechner die online sind)
Und habe da ein Problem:
Ich will mit _TCPIpToName die Namen der Rechner (Nicht nur die IP anzeigen, aber irgendwie gibt _TCPIpToName immer nur "" (Fehler) zurück...
Ich habe keine ahnung warum...
Hier ist mein Code:
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <INet.au3>
#Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\keno\eigene dateien\eigene dokumente\koda\ping subnet.kxf
$Form1 = GUICreate("Ping Subnet", 423, 450, 192, 124)
$range = GUICtrlCreateInput("192.168.0.xxx", 0, 0, 121, 21)
$go = GUICtrlCreateButton("Go", 184, 0, 75, 25, $WS_GROUP)
$found = GUICtrlCreateEdit("", 0, 40, 273, 409)
$MaxIp = GUICtrlCreateInput("100", 136, 0, 41, 21)
$addfield = GUICtrlCreateInput("IP", 288, 40, 121, 21)
$add = GUICtrlCreateButton("Add zu known IPs", 288, 96, 99, 25, $WS_GROUP)
$addname = GUICtrlCreateInput("Name", 288, 64, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$msg = GUIGetMsg ()
If $msg = -3 Then Exit
If $msg = $go Then
GUICtrlSetData ($found, "")
$max = GUICtrlRead ($maxIp)
GUICtrlSetData ($go, "Stop")
GUICtrlSetState ($MaxIp, $GUI_DISABLE)
GUICtrlSetState ($add, $GUI_DISABLE)
GUICtrlSetState ($addfield, $GUI_DISABLE)
GUICtrlSetState ($addname, $GUI_DISABLE)
GUICtrlSetState ($range, $GUI_DISABLE)
$split = StringSplit (GUICtrlRead ($range), "xxx")
$split[2] = $split[1]
$i = 1
WinSetTitle ("Ping Subnet", "","Scanning: " & $split[2] & $i)
Do
$ping = Ping ($split[2] & $i, 500)
If $ping <> 0 Then
$read = GUICtrlRead ($found)
$name = _TCPIpToName ($split[2] & $i)
If $name == "" Then
GUICtrlSetData ($found, $read & IniRead (@ScriptDir & "\names.ini", "names", $split[2] & $i, $split[2] & $i) & " " & $ping & "ms" & @CRLF)
Else
GUICtrlSetData ($found, $read & $name & " " & $ping & "ms" & @CRLF)
EndIf
EndIf
$i += 1
WinSetTitle ("Scanning: " & $split[2] & $i -1, "", "Scanning: " & $split[2] & $i)
If GUIGetMsg () = $go Then ExitLoop
Until $i = $max
GUICtrlSetData ($go, "Go")
WinSetTitle ("Scanning: " & $split[2] & $i, "", "Ping Subnet")
GUICtrlSetState ($MaxIp, $GUI_ENABLE)
GUICtrlSetState ($add, $GUI_ENABLE)
GUICtrlSetState ($addfield, $GUI_ENABLE)
GUICtrlSetState ($addname, $GUI_ENABLE)
GUICtrlSetState ($range, $GUI_ENABLE)
EndIf
If $msg = $add Then
IniWrite (@ScriptDir & "\names.ini", "Names", GUICtrlRead ($addfield), GUICtrlRead ($addname))
GUICtrlSetData ($addfield, "IP")
GUICtrlSetData ($addname, "Name")
EndIf
WEnd
Thx schonmal