My2009 发表于 2009-7-13 13:33:09

如何得到本地连接速度??

当我们将鼠标放在电脑右下脚的闪亮网络连接上时发有提示出来“本地连接速度为:100M/1000M”,现太就想知道,AUTOIT能得到这个100或1000的这个数值吗??

dfasd 发表于 2009-7-19 14:42:31

帮你顶上去

My2009 发表于 2009-8-17 18:35:43

还没有人回答??

pusofalse 发表于 2009-8-17 19:09:38

你始终不是遇到此问题的第一人,善用搜索。

My2009 发表于 2009-8-24 11:04:23

:face (30):找了,都没有一个能实现的!!!

pusofalse 发表于 2009-8-24 11:39:54

你找的哪个?贴上来看下?

My2009 发表于 2009-8-25 14:27:35

$test = GetIfEntry(1)
   MsgBox(0,"",$test & " MB")
Func GetIfEntry($ifIndex)
        Const $MAX_INTERFACE_NAME_LEN = 256
        Const $MAXLEN_PHYSADDR=8
        Const $MAXLEN_IFDESCR=256
       
        ; Create struct MIB_IPFORWARDROW
        $Str_IfRow="short;dword;dword;dword;dword;dword;char;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;char"
        $Struct_MIB_IFROW= DllStructCreate($Str_IfRow)
        if @error then Return
       
        DllStructSetData($Struct_MIB_IFROW,2,$ifIndex)        ; dwIndex
    ;DLLStructGetData($Struct_MIB_IFROW,6)
       
        $Res = DLLCall("iphlpapi.dll","long","GetIfEntry","ptr",DllStructGetPtr($Struct_MIB_IFROW))
        if @error or $Res<>0 then
                consolewrite("GetIfEntry: dllcall error: " & @error & " $res=" & $Res & @CR)
                Return
        EndIf
        Return DLLStructGetData($Struct_MIB_IFROW,5) /10000
               
Endfunc

不管是千兆还是百兆的都跳出1000

pusofalse 发表于 2009-8-25 15:16:43

Re 7#:
试下这个,关键是GetIfEntry的ifIndex这个参数要正确,可能每台电脑都会有所不同(?),我这里是2。另外你在7#的代码,最后怎么是/10000呢?速度是以字节为单位的,/10000就可以转成MB了?
如果你不确定网卡的适配器索引,可以看下这个帖子:http://www.autoitx.com/forum.php?mod=viewthread&tid=8533$iSpeed = GetIfEntry(2)
MsgBox(0, @error, $iSpeed & " MB")

Func GetIfEntry($ifIndex)
        Local $tagBuffer, $tBuffer, $pBuffer, $iResult, $iSpeed, $sDescr

        $tagBuffer = "wchar;dword;byte;dword;char"
              $tBuffer = DllStructCreate($tagBuffer)
        $pBuffer = DllStructGetPtr($tBuffer)
        DllStructSetData($tBuffer, 2, $ifIndex, 1)

        $iResult = DllCall("iphlpapi.dll","long","GetIfEntry","ptr", $pBuffer)
        $iSpeed = DllStructGetData($tBuffer, 2, 4) / 1000 / 1000
        $sDescr = DllStructGetData($tBuffer, 5)
        $tBuffer = 0
        Return SetError($iResult, $iSpeed, $iSpeed)
Endfunc        ;==>GetIfEntry

My2009 发表于 2009-9-7 16:17:22

你的代码运行后的结果是0MB

pusofalse 发表于 2009-9-7 16:21:36

Re 9#:
不可能不行。
你不会是直接运行了吧?你确定_GetIfEntry的$ifIndex值正确无误?

afan 发表于 2009-9-7 16:23:31

我这正常显示速度~

My2009 发表于 2009-11-13 08:18:47

本帖最后由 My2009 于 2009-11-25 19:30 编辑

晕倒,有解决之道吗??自己再顶下先:face (31):
页: [1]
查看完整版本: 如何得到本地连接速度??