找回密码
 加入
搜索
查看: 2086|回复: 1

[系统综合] 获进程CPU 使用率老错误

[复制链接]
发表于 2011-8-1 22:02:32 | 显示全部楼层 |阅读模式
#include <file.au3>
#include <Array.au3>

$Process="kwmusic.exe"
$Process="MyPopo.exe"
$sComputer = "."
Dim $log = "55.log"
Opt("GUIOnEventMode", 1)
dim $hong=@ScriptDir 
_FileWriteLog($hong & $log, "5555")
;_FileWriteLog($hong & $log, _ProcessListProperties($Process = "", $sComputer = "."))
$aThread = _ProcessListProperties($Process, $sComputer)
_FileWriteLog($hong & $log, $aThread)
Dim   $avProcs1
Dim   $avProcs2

Func _ProcessListProperties($Process = "", $sComputer = ".")
        
        Local $sUserName, $sUserDomain, $dtmDateD
        Local $avProcs[1][2] = [[0]], $n = 1
        Local $oWMI, $colProcs 
        If StringIsInt($Process) Then $Process = Int($Process)
        $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate, authenticationLevel=pktPrivacy, (Debug)}!\" & $sComputer & "\root\CIMV2")
                                $colProcs = $oWMI.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " & $Process)
                Local $oRefresher = ObjCreate("WbemScripting.SWbemRefresher")
                $colProcs = $oRefresher.AddEnum($oWMI, "Win32_PerfFormattedData_PerfProc_Process").objectSet
                $oRefresher.Refresh
                Local $iTime = TimerInit()
                Do
                        Sleep(20)
                Until TimerDiff($iTime) >= 100
                $oRefresher.Refresh
                                While True
                                        $avProcs1 = $colProcs.PercentProcessorTime
                                        $avProcs2= $colProcs.WorkingSet
                                WEnd
                                 Return $avProcs1 & $avProcs2
EndFunc 
                  
发表于 2011-8-2 07:45:23 | 显示全部楼层
cpu使用率还是去找找pdh吧,这样算出来的都不太准
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-14 14:15 , Processed in 0.357731 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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