回复 4# cxq7668
終於知道句柄數是啥了
轉貼的
請自行加判斷$arProc = ProcessList("QQ.exe")
For $i = 1 to $arProc[0][0]
$arStat = ProcessGetStats($arProc[$i][1], 0)
If IsArray($arStat) Then
ConsoleWrite("Process Name: " & $arProc[$i][0] & " - Handle: " & StringReplace(_ProcessGetHandle($arProc[$i][0]), @LF, " - ") & @CRLF)
EndIf
Next
Func _ProcessGetHandle($ioProcName)
If $ioProcName Then
Local $sStatus = Run(@ComSpec & " /c WMIC PROCESS WHERE Name='" & $ioProcName & "' GET handlecount", @SystemDir, @SW_HIDE, 8)
Local $sBuf
While 1
$sBuf &= StdoutRead($sStatus)
If @Error then ExitLoop ; We have lift off, let's move on!
WEnd
$sBuf = StringStripCR($sBuf)
$sBuf = StringRegExpReplace($sBuf, "HandleCount", "")
$sBuf = StringStripWS($sBuf, 3)
If StringInStr($sBuf, "No Instance(s) Available.") Then
; Just incase we enter a bad process name
SetError(2)
Return 0
EndIf
Return $sBuf
Else
SetError(1)
Return 0
EndIf
EndFunc
|