找回密码
 加入
搜索
查看: 2179|回复: 3

[系统综合] CPU和内存使都不对?大哥们帮看下,哪里不对,帮测下

  [复制链接]
发表于 2011-8-2 21:14:23 | 显示全部楼层 |阅读模式
#include <String.au3>
#include <GUIConstantsEx.au3>

$Form1 = GUICreate("显示统计", 200, 120, 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)
$Label5 = GUICtrlCreateLabel("cpu使用率:", 24, 56, 80, 17)
$Label6 = GUICtrlCreateLabel("0", 88, 56, 100, 17)
$Label7 = GUICtrlCreateLabel("0", 108, 80, 130, 17)
$Label8 = GUICtrlCreateLabel("内存使用率:", 24, 80, 80, 17)

GUISetState(@SW_SHOW)
WinSetOnTop ($Form1,"",1) 

$_IfTable=_GetIfTable()
Global $_Down=$_IfTable[0]
Global $_UpDate=$_IfTable[1]
Global $cpuvalus
Global $ramvalus
AdlibRegister ("_Strat_Time",500)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                       Exit
        EndSwitch

WEnd
Func _Strat_Time()
        $_IfTable=_GetIfTable()
                $cpuvalus=_CPU()
                $ramvalus=MemGetStats ( )
        GUICtrlSetData ($Label2, Round(($_IfTable[1]-$_UpDate)/1024,2)& " Kb")
        GUICtrlSetData ($Label3, Round(($_IfTable[0]-$_Down)/1024,2) & " Kb")
                GUICtrlSetData ($Label6, $cpuvalus & "%")
        GUICtrlSetData ($Label7, $ramvalus[1]-$ramvalus[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

Func _CPU()
        $wbemServices = ObjGet("winmgmts:\\.\root\cimv2") 
    $wbemObjectSet= $wbemServices.ExecQuery("Select * from Win32_Processor")
    For $wbemObject In $wbemObjectSet 
       $cpuvalus2=$wbemObject.LoadPercentage
   Next
    Return $cpuvalus2
EndFunc
发表于 2011-8-2 22:03:07 | 显示全部楼层
移动好卡,关闭无响应,试试事件模式呢。
发表于 2011-8-9 17:30:50 | 显示全部楼层
的确很卡呀
发表于 2011-8-10 08:37:17 | 显示全部楼层
好卡好卡....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-11 09:03 , Processed in 0.088192 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表