#include <String.au3>
#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 192, 67, 445, 376)
$Label1 = GUICtrlCreateLabel("上传速度:", 24, 8, 55, 17)
$Label2 = GUICtrlCreateLabel("0", 88, 8, 100, 17)
$Label3 = GUICtrlCreateLabel("0", 88, 32, 100, 17)
$Label4 = GUICtrlCreateLabel("下载速度:", 24, 32, 55, 17)
GUISetState(@SW_SHOW)
WinSetOnTop ($Form1,"",1)
$_IfTable=_GetIfTable()
Global $_Down=$_IfTable[0]
Global $_UpDate=$_IfTable[1]
AdlibRegister ("_Strat_Time",1000)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _Strat_Time()
$_IfTable=_GetIfTable()
GUICtrlSetData ($Label2, Round(($_IfTable[1]-$_UpDate)/1024,2)& " Kb")
GUICtrlSetData ($Label3, Round(($_IfTable[0]-$_Down)/1024,2) & " Kb")
Global $_Down=$_IfTable[0]
Global $_UpDate=$_IfTable[1]
EndFunc
Func _GetIfTable()
$_Return=DllCall("Iphlpapi.dll","long","GetIfTable","ptr",0,"ulong*",0,"int",0)
$_aBuffer=DllStructCreate("byte[" & $_Return[2] & "]")
$_Return=DllCall("Iphlpapi.dll","long","GetIfTable","ptr",DllStructGetPtr($_aBuffer),"ulong*",DllStructGetSize($_aBuffer),"int",0)
$_Number=DllStructCreate("dword",DllStructGetPtr($_aBuffer))
$_Number=DllStructGetData($_Number,1)
$_MIB_IFROW="dword" & _StringRepeat(";wchar[256];dword[5];byte[8];dword[16];byte[256]",$_Number)
$_MIB_IFTABLE=DllStructCreate($_MIB_IFROW,DllStructGetPtr($_aBuffer))
Dim $_Table[2]
For $i=2 To $_Number * 5 Step 5
$_Table[0]+=DllStructGetData($_MIB_IFTABLE,$i+3,4)
$_Table[1]+=DllStructGetData($_MIB_IFTABLE,$i+3,10)
Next
Return $_Table
EndFunc