回复 14# FluxayX
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_icon=C:\WINDOWS\system32\SHELL32.dll|-23
#PRE_Outfile=高速PING工具.exe
#PRE_Res_Comment=QQ:6910930
#PRE_Res_Description=高速PING工具 V2.0
#PRE_Res_Fileversion=1.0.0.10
#PRE_Res_Fileversion_AutoIncrement=p
#PRE_Res_LegalCopyright=Soft by Tvzml
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <GuiIPAddress.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <ProgressConstants.au3>
Opt("GUICloseOnESC", 0)
Opt("TrayMenuMode", 1)
Opt('MustDeclareVars', 1)
Local $ISTEST = False, $IP_Mac_Arrar[1][5]
Global Const $DONT_FRAGMENT = 2, $IP_SUCCESS = 0, $IP_DEST_NET_UNREACHABLE = 11002, $IP_DEST_HOST_UNREACHABLE = 11003, $IP_DEST_PROT_UNREACHABLE = 11004, $IP_DEST_PORT_UNREACHABLE = 11005, _
$IP_NO_RESOURCES = 11006, $IP_HW_ERROR = 11008, $IP_PACKET_TOO_BIG = 11009, $IP_REQ_TIMED_OUT = 11010, $IP_BAD_REQ = 11011, $IP_BAD_ROUTE = 11012, _
$IP_TTL_EXPIRED_TRANSIT = 11013, $IP_TTL_EXPIRED_REASSEM = 11014, $IP_PARAM_PROBLEM = 11015, $IP_SOURCE_QUENCH = 11016, $IP_BAD_DESTINATION = 11018, _
$IP_GENERAL_FAILURE = 11050, $NO_STATUS = 10000 ;We will use 10000 as the no status indicator since 0 meens successful reply
Global $hPointers, $hkernel32Dll = -1, $hICMPDll, $hICMPDll, $DllData, $PINGJG = -1, $country, $area, $sleep = 0
Local $PING_1 = 5, $PING_2 = 30
Local $pings[1] = [0]
Local $pings_array[1][4]
Local $pingdata = "x"
Local $timeout = 300
Local $ttl = 255
Local $IPQJ = "192.168.0."
Local $files = @ScriptDir & "\LOLTOOLS.INI"
Local $TT_Main = "高速PING工具 V2.0", $Width = 610, $Height = 490
Local $hGUI = GUICreate($TT_Main, $Width, $Height)
Local $tabx = 131, $taby = 70, $tabw = 472, $tabh = 360
Local $Button3 = GUICtrlCreateButton("点击测试PING", $tabx + 4, 10, $tabw - 8, 60)
GUICtrlSetCursor(-1, 0)
GUICtrlSetFont(-1, 20, 400, "微软雅黑")
Local $hListView = GUICtrlCreateListView("", $tabx + 4, $taby + 23, $tabw - 8, $tabh - 30, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
_GUICtrlListView_AddColumn($hListView, "序号", 50)
_GUICtrlListView_AddColumn($hListView, "名称", 170)
_GUICtrlListView_AddColumn($hListView, "IP地址", 110)
_GUICtrlListView_AddColumn($hListView, "状态", 110, 0)
_GUICtrlListView_AddColumn($hListView, "", 0)
_GUICtrlListView_AddColumn($hListView, "", 0)
Local $hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0xFFFFFF, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0x00FF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0xFFFF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0xFF0000, 16, 16))
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
Local $hGUIEdit = GUICtrlCreateEdit("", $tabx + 4, $taby + $tabh - 5, $tabw - 8, 50, $ES_AUTOVSCROLL)
GUISetState(@SW_SHOW, $hGUI)
Local $progress = GUICtrlCreateProgress($tabx + 4, $taby + 23 - 15, $tabw - 8, 15, $PBS_SMOOTH)
_loadIpList()
While 1
If Not $ISTEST Then _While()
WEnd
Func _While()
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_exit()
Case $Button3
_loadIpList()
EndSwitch
If $sleep > 0 Then
$sleep -= 1
Sleep(50)
EndIf
EndFunc ;==>_While
Func Echo($line = "")
Dim $time, $hGUIEdit_Str, $hGUIEdit_StrSp, $hGUIEdit_StrOK = "", $hGUIEdit_StrMax = 2, $hGUIEdit_StrEnd
$hGUIEdit_Str = GUICtrlRead($hGUIEdit)
If StringInStr($hGUIEdit_Str, @CRLF) Then
$hGUIEdit_StrSp = StringSplit($hGUIEdit_Str, @CRLF, 1)
If IsArray($hGUIEdit_StrSp) Then
Dim $hGUIEdit_Strout = UBound($hGUIEdit_StrSp) - 1
If $hGUIEdit_Strout > $hGUIEdit_StrMax Then
$hGUIEdit_StrMax = $hGUIEdit_Strout - $hGUIEdit_StrMax
Else
$hGUIEdit_StrMax = 1
EndIf
For $i = $hGUIEdit_StrMax To UBound($hGUIEdit_StrSp) - 1
$hGUIEdit_StrOK = StringReplace($hGUIEdit_StrOK, @CRLF, '^')
$hGUIEdit_StrOK = $hGUIEdit_StrOK & $hGUIEdit_StrSp[$i] & '^'
$hGUIEdit_StrOK = StringReplace($hGUIEdit_StrOK, '^^', '^')
Next
EndIf
EndIf
If $hGUIEdit_StrOK <> "" Then
$hGUIEdit_StrEnd = $hGUIEdit_StrOK & '^' & _Time() & " " & $line
Else
$hGUIEdit_StrEnd = _Time() & " " & $line
EndIf
$hGUIEdit_StrEnd = StringReplace($hGUIEdit_StrEnd, '^^', '^')
$hGUIEdit_StrEnd = _TrimStr($hGUIEdit_StrEnd, "^")
$hGUIEdit_StrEnd = StringReplace($hGUIEdit_StrEnd, '^', @CRLF)
GUICtrlSetData($hGUIEdit, $hGUIEdit_StrEnd & @CRLF)
EndFunc ;==>Echo
Func _Time()
Return @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
EndFunc ;==>_Time
Func _TrimStr($str = "", $delstr = "\")
If StringLeft($str, 1) = $delstr Then $str = StringTrimLeft($str, 1)
If StringRight($str, 1) = $delstr Then $str = StringTrimRight($str, 1)
Return $str
EndFunc ;==>_TrimStr
Func _exit()
Exit
EndFunc ;==>_exit
Func _GetLoLIP($hiurl = "")
If $hiurl <> "" Then
Dim $String
If InetGet($hiurl, @TempDir & "\~ip.tmp") Then
$String = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
FileDelete(@TempDir & "\~ip.tmp")
Return _GetStringTrim($String, "@", 1, "@")
EndIf
EndIf
EndFunc ;==>_GetLoLIP
Func _GetStringTrim($String, $Begin, $BeginPosition, $End, $EndPosition = 1)
Local $Point[2], $String1
$Point[0] = StringInStr($String, $Begin, 0, $BeginPosition)
If $Point[0] > 0 Then
$Point[0] += StringLen($Begin)
$Point[1] = StringInStr($String, $End, 0, $EndPosition, $Point[0])
If $Point[1] > 0 Then
$String1 = StringMid($String, $Point[0], $Point[1] - $Point[0])
$String1 = _decstr($String1, "<br />")
$String1 = _decstr($String1, "</span>")
$String1 = _decstr($String1, '<span style="">')
$String1 = _decstr($String1, ' ')
$String1 = _decstr($String1, " ")
$String1 = StringReplace($String1, "<p>", "|")
$String1 = StringReplace($String1, "</p>", "|")
$String1 = StringReplace($String1, "||", "|")
Return $String1
EndIf
EndIf
Return ""
EndFunc ;==>_GetStringTrim
Func _decstr($String2, $str)
Dim $String3
$String3 = $String2
For $i = 1 To StringLen($String2) / StringLen($str)
If StringInStr($String3, $str) = 0 Then ExitLoop
$String3 = StringReplace($String3, $str, "")
Next
Return $String3
EndFunc ;==>_decstr
Func _loadIpList()
Dim $CC = 0, $PINGJG_str
Dim $PING_1_FILE = IniRead($files, "延迟设置", "内网延迟", "NOT")
If Not $PING_1_FILE = "NOT" Then
$PING_1 = Int($PING_1_FILE)
Else
IniWrite($files, "延迟设置", "内网延迟", $PING_1)
EndIf
Dim $PING_2_FILE = IniRead($files, "延迟设置", "外网延迟", "NOT")
If Not $PING_2_FILE = "NOT" Then
$PING_2 = Int($PING_2_FILE)
Else
IniWrite($files, "延迟设置", "外网延迟", $PING_2)
EndIf
ReDim $IP_Mac_Arrar[1][6]
Dim $Read_mac = IniReadSection($files, "内网IP")
If IsArray($Read_mac) Then
If UBound($Read_mac) > 1 Then
For $i = 0 To UBound($Read_mac) - 1
If $Read_mac[$i][1] <> "" Then
Dim $UBound = UBound($IP_Mac_Arrar)
ReDim $IP_Mac_Arrar[$UBound + 1][6]
;Dim $Mac_ip_sp_SP = StringSplit($Read_mac[$i][1], ".", 1)
;If IsArray($Mac_ip_sp_SP) Then
;If UBound($Mac_ip_sp_SP) = 5 Then
$IP_Mac_Arrar[$UBound][0] = $Read_mac[$i][0]
$IP_Mac_Arrar[$UBound][1] = $Read_mac[$i][1]
$IP_Mac_Arrar[$UBound][3] = "[内网]"
;EndIf
;EndIf
EndIf
Next
EndIf
EndIf
Dim $Read_mac = IniReadSection($files, "外网IP")
If IsArray($Read_mac) Then
If UBound($Read_mac) > 1 Then
For $i = 0 To UBound($Read_mac) - 1
If $Read_mac[$i][1] <> "" Then
Echo($Read_mac[$i][1])
Dim $UBound = UBound($IP_Mac_Arrar)
ReDim $IP_Mac_Arrar[$UBound + 1][6]
;Dim $Mac_ip_sp_SP = StringSplit($Read_mac[$i][1], ".", 1)
;If IsArray($Mac_ip_sp_SP) Then
;If UBound($Mac_ip_sp_SP) = 5 Then
$IP_Mac_Arrar[$UBound][0] = $Read_mac[$i][0]
$IP_Mac_Arrar[$UBound][1] = $Read_mac[$i][1]
$IP_Mac_Arrar[$UBound][3] = "[外网]"
;EndIf
;EndIf
EndIf
Next
EndIf
EndIf
If IsArray($IP_Mac_Arrar) Then
If UBound($IP_Mac_Arrar) > 1 Then
$sleep = Int(UBound($IP_Mac_Arrar)) * 1
GUICtrlSetData($progress, 0)
For $i = 1 To UBound($IP_Mac_Arrar) - 1
If $IP_Mac_Arrar[$i][1] <> "" Then
$PINGJG = -1
_While()
_PINGALL(_TCPNameToIP($IP_Mac_Arrar[$i][1]))
$PINGJG_str = ""
If $PINGJG = -1 Then
$PINGJG_str = "故障"
$CC = 3
EndIf
If $PINGJG = 0 Then
$PINGJG_str = "正常(<1ms)"
$CC = 1
EndIf
If $IP_Mac_Arrar[$i][3] = "[内网]" Then
If $PINGJG > 0 And $PINGJG < $PING_1 + 1 Then
$PINGJG_str = "正常(" & $PINGJG & "ms)"
$CC = 1
EndIf
If $PINGJG > $PING_1 Then
$PINGJG_str = "延迟(" & $PINGJG & "ms)"
$CC = 2
EndIf
EndIf
If $IP_Mac_Arrar[$i][3] = "[外网]" Then
If $PINGJG > 0 And $PINGJG < $PING_2 + 1 Then
$PINGJG_str = "正常(" & $PINGJG & "ms)"
$CC = 1
EndIf
If $PINGJG > $PING_2 Then
$PINGJG_str = "延迟(" & $PINGJG & "ms)"
$CC = 2
EndIf
EndIf
$IP_Mac_Arrar[$i][2] = $PINGJG_str
GUICtrlSetData($progress, $i * (100 / UBound($IP_Mac_Arrar)))
Dim $iI = _GUICtrlListView_FindText($hListView, $i, 0)
If $iI = -1 Then
_GUICtrlListView_AddItem($hListView, $i, 0)
_GUICtrlListView_AddSubItem($hListView, $i - 1, $IP_Mac_Arrar[$i][0], 1)
_GUICtrlListView_AddSubItem($hListView, $i - 1, $IP_Mac_Arrar[$i][1], 2)
_GUICtrlListView_AddSubItem($hListView, $i - 1, $PINGJG_str, 3, $CC)
Else
_GUICtrlListView_SetItem($hListView, $PINGJG_str, $iI, 3, $CC)
EndIf
EndIf
Next
GUICtrlSetData($progress, 100)
EndIf
EndIf
EndFunc ;==>_loadIpList
Func _PINGALL($pingstr = "")
ReDim $pings_array[1][4]
$hPointers = DllStructCreate("ptr IcmpCloseHandle;ptr IcmpSendEcho;ptr IcmpCreateFile;ptr ExitThread")
If $hkernel32Dll = -1 Then $hkernel32Dll = DllOpen("kernel32.dll")
Dim $hKrn = _WinAPI_GetModuleHandle("kernel32.dll")
DllStructSetData($hPointers, "ExitThread", GetProcAddress($hKrn, "ExitThread"))
$hICMPDll = LibLoad("ICMP.dll");Iphlpapi.dll")
DllStructSetData($hPointers, "IcmpCloseHandle", GetProcAddress($hICMPDll, "IcmpCloseHandle"))
DllStructSetData($hPointers, "IcmpSendEcho", GetProcAddress($hICMPDll, "IcmpSendEcho"))
DllStructSetData($hPointers, "IcmpCreateFile", GetProcAddress($hICMPDll, "IcmpCreateFile"))
pingThreaded($pingstr, $timeout, $pingdata, $ttl, $DONT_FRAGMENT)
While $pings[0] > 0
_managePings()
WEnd
LibFree($hICMPDll)
If $hkernel32Dll <> -1 Then
DllClose($hkernel32Dll)
$hkernel32Dll = -1
EndIf
EndFunc ;==>_PINGALL
Func pingThreaded($ip_addr, $timeout = 5000, $data = "x", $ttl = 255, $flags = 0)
Local $hexIP = encodeIP($ip_addr)
If $hexIP == 0 Then Return 0
Local $pingID = _addPing($ip_addr)
If IsNumber($ttl) = 0 Or Number($ttl) > 255 Then $ttl = 255
If IsNumber($timeout) = 0 Or Number($timeout) > 5000 Then $timeout = 5000
If StringLen($data) > 256 Then $data = StringTrimRight($data, StringLen($data) - 256)
If IsNumber($flags) = 0 Or Number($flags) > 2 Then $flags = 2
DllStructSetData($pings[$pingID], "datasize", StringLen($data)) ;We may wish to report the data size later
Local $CodeBuffer = DllStructCreate("byte[696]"); Code=154, Data=256, Echo reply Struct + ICMP_OPTIONS Struct = 286
Local $RemoteCode = _MemVirtualAlloc(0, DllStructGetSize($CodeBuffer), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE)
DllStructSetData($CodeBuffer, 1, _
"0x" & _ ;Original Assembly started at 401000
"E889000000" & _ ;Call 0040108E <IcmpCreateFile>
"A3" & SwapEndian($RemoteCode + 410) & _ ;mov dword ptr [00403010], eax <hIcmp = IcmpCreateFile Handle>
"C605" & SwapEndian($RemoteCode + 418) & Hex($ttl, 2) & _ ;mov byte ptr [00403024], xx <TTL>
"C605" & SwapEndian($RemoteCode + 419) & "00" & _ ;mov byte ptr [00403025], 00 <TOS>
"C605" & SwapEndian($RemoteCode + 420) & Hex($flags, 2) & _ ;mov byte ptr [00403026], 02 <Flags, 0x02=DF Bit Set>
"C605" & SwapEndian($RemoteCode + 421) & "00" & _ ;mov byte ptr [00403027], 00
"C705" & SwapEndian($RemoteCode + 422) & "00000000" & _ ;mov dword ptr [00403028], 00000000
"68" & SwapEndian(Dec(Hex($timeout, 4))) & _ ;push 0000xxxx <Timeout>
"681E010000" & _ ;push 0000011E <Size of Echo reply Struct + ICMP_OPTIONS Struct>
"68" & SwapEndian($RemoteCode + 426) & _ ;push 0040302C <icmpReply>
"68" & SwapEndian($RemoteCode + 418) & _ ;push 00403024 <icmpOptions>
"6A" & Hex(StringLen($data), 2) & _ ;push 000000xx <Data Size>
"68" & SwapEndian($RemoteCode + 154) & _ ;push 00403000 <Data>
"68" & SwapEndian(Dec($hexIP)) & _ ;push <Hex(IP ADDRESS)>
"FF35" & SwapEndian($RemoteCode + 410) & _ ;push dword ptr [00403010] <hIcmp>
"E839000000" & _ ;Call 00401094 <IcmpSendEcho>
"A1" & SwapEndian($RemoteCode + 434) & _ ;mov eax, dword ptr [00403034] <Get the ms responce time from icmpReply.RoundTripTime>
"A3" & SwapEndian(DllStructGetPtr($pings[$pingID], "reply")) & _ ;mov dword ptr [0040301C], eax <Store the ms responce time>
"A1" & SwapEndian($RemoteCode + 430) & _ ;mov eax, dword ptr [00403030] <Get the status from icmpReply.Status>
"A3" & SwapEndian(DllStructGetPtr($pings[$pingID], "status")) & _ ;mov dword ptr [00403020], eax <Store the status>
"FF35" & SwapEndian($RemoteCode + 410) & _ ;push dword ptr [00403010] <hIcmp>
"E80E000000" & _ ;Call 00401088 <IcmpCloseHandle>
"6A00" & _ ;push 00000000
"E801000000" & _ ;Call 00401082 <ExitThread>
"CC" & _ ;int 03
"FF25" & SwapEndian(DllStructGetPtr($hPointers, "ExitThread")) & _ ;JMP dword ptr <kernel32.ExitThread>
"FF25" & SwapEndian(DllStructGetPtr($hPointers, "IcmpCloseHandle")) & _ ;JMP dword ptr <ICMP.IcmpCloseHandle>
"FF25" & SwapEndian(DllStructGetPtr($hPointers, "IcmpCreateFile")) & _ ;JMP dword ptr <ICMP.IcmpCreateFile>
"FF25" & SwapEndian(DllStructGetPtr($hPointers, "IcmpSendEcho")) & _ ;JMP dword ptr <ICMP.IcmpSendEcho>
SwapEndian(StringToBinary($data)) _ ;This is our ping Data, Max 256 bytes of space here.
)
_MemMoveMemory(DllStructGetPtr($CodeBuffer), $RemoteCode, DllStructGetSize($CodeBuffer))
Local $aCall = DllCall($hkernel32Dll, "ptr", "CreateThread", "ptr", 0, "int", 0, "ptr", $RemoteCode, "ptr", 0, "int", 0, "dword*", 0)
Return $aCall[0]
EndFunc ;==>pingThreaded
Func _addPing($ip_addr)
$pings[0] = UBound($pings)
ReDim $pings[$pings[0] + 1]
$pings[$pings[0]] = DllStructCreate("char ip[" & StringLen($ip_addr) & "];ulong reply;ulong status;int datasize");You could add a timeout struct here
DllStructSetData($pings[$pings[0]], "ip", $ip_addr)
DllStructSetData($pings[$pings[0]], "status", $NO_STATUS)
Return $pings[0]
EndFunc ;==>_addPing
Func _removePing($pingID)
If $pingID > $pings[0] Then Return ;Ensure our ID is valid
$pings[$pingID] = 0 ;Free the DLLStruct
_ArrayDelete($pings, $pingID)
$pings[0] -= 1
EndFunc ;==>_removePing
Func _managePings()
Local $pingID, $status
$pingID = 1
While $pingID <= $pings[0]
$status = DllStructGetData($pings[$pingID], "status")
If $status <> $NO_STATUS Then
Switch $status
Case $IP_SUCCESS
Dim $pings_UBound = UBound($pings_array)
ReDim $pings_array[$pings_UBound + 1][4]
Dim $ipstr = DllStructGetData($pings[$pingID], "ip")
Dim $ipstrSP = StringSplit($ipstr, ".", 1)
If IsArray($ipstrSP) Then
If UBound($ipstrSP) > 4 Then
$pings_array[$pings_UBound - 1][3] = Int($ipstrSP[4])
EndIf
EndIf
$pings_array[$pings_UBound - 1][1] = $ipstr
If DllStructGetData($pings[$pingID], "reply") = 0 Then
;ConsoleWrite("Ping with " & DllStructGetData($pings[$pingID], "datasize") & " byte(s) to " & DllStructGetData($pings[$pingID], "ip") & " replied in <1ms" & @CRLF)
$pings_array[$pings_UBound - 1][2] = "<1ms"
$PINGJG = 0
Else
;ConsoleWrite("Ping with " & DllStructGetData($pings[$pingID], "datasize") & " byte(s) to " & DllStructGetData($pings[$pingID], "ip") & " replied in " & DllStructGetData($pings[$pingID], "reply") & "ms" & @CRLF)
$pings_array[$pings_UBound - 1][2] = DllStructGetData($pings[$pingID], "reply") & "ms"
$PINGJG = Number(DllStructGetData($pings[$pingID], "reply"))
EndIf
EndSwitch
_removePing($pingID)
EndIf
$pingID += 1
WEnd
EndFunc ;==>_managePings
Func encodeIP($ip_addr)
Local $ip_addr_temp = $ip_addr
If Not _isIP($ip_addr) Then $ip_addr = TCPNameToIP($ip_addr)
If Not _isIP($ip_addr) Then
ConsoleWrite($ip_addr_temp & " is not a valid IP Address. If you supplied a hostname ensure DNS is available." & @CRLF)
Return 0
EndIf
Return getHexIP($ip_addr)
EndFunc ;==>encodeIP
Func getHexIP($ip_addr)
Return Hex(_getIPOctet($ip_addr, 4), 2) & Hex(_getIPOctet($ip_addr, 3), 2) & Hex(_getIPOctet($ip_addr, 2), 2) & Hex(_getIPOctet($ip_addr, 1), 2)
EndFunc ;==>getHexIP
Func LibLoad($lpLibFileName)
Local $LibHandle = DllCall($hkernel32Dll, "int", "LoadLibraryA", "str", $lpLibFileName)
Return $LibHandle[0]
EndFunc ;==>LibLoad
Func LibFree($DllHandle)
Local $LibFreed = DllCall($hkernel32Dll, "int", "FreeLibrary", "int", $DllHandle)
Return $LibFreed[0]
EndFunc ;==>LibFree
Func GetProcAddress($hModule, $lpProcName)
Local $ProcessAddy = DllCall($hkernel32Dll, "int", "GetProcAddress", "int", $hModule, "str", $lpProcName)
Return $ProcessAddy[0]
EndFunc ;==>GetProcAddress
Func SwapEndian($hex)
Return Hex(Binary($hex))
EndFunc ;==>SwapEndian
Func _getIPOctet($ip_addr, $octet = 1)
Switch $octet
Case 1
Return Int(StringMid($ip_addr, 1, StringInStr($ip_addr, ".")))
Case 4
Return Int(StringMid($ip_addr, StringInStr($ip_addr, ".", 0, 3) + 1))
Case Else
Return Int(StringMid($ip_addr, StringInStr($ip_addr, ".", 0, $octet - 1) + 1, StringInStr($ip_addr, ".", 0, $octet) + 1))
EndSwitch
EndFunc ;==>_getIPOctet
Func _isIP($text)
Return StringRegExp($text, "(((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))")
EndFunc ;==>_isIP
Func _TCPNameToIP($str)
Dim $TP_NAMETOIP = $str
If Not StringIsDigit(StringReplace($TP_NAMETOIP, ".", "")) Then
TCPStartup()
$TP_NAMETOIP = TCPNameToIP($str) ;域名转换为IP
TCPShutdown()
EndIf
Return $TP_NAMETOIP
EndFunc ;==>_TCPNameToIP
|