好吧,我承认我5#的回复实在是多余了,楼主觉得呢?
#include <Thread.au3>
$iProcessId = ProcessExists("Notepad.exe")
If ($iProcessId = 0) Then Exit
$aThread = _RTEnumerateThreads($iProcessId)
If ($aThread[1][6] = 5) And ($aThread[1][7] = 5) Then
MsgBox(48, "", "Process " & $iProcessId & " is suspended.")
Else
MsgBox(48, "", "Process " & $iProcessId & " is not suspended.")
EndIf
_RTEnumerateThreads 原型:
Func _RTEnumerateThreads($iProcessId = 0)
Local $pBuffer, $iOffset, $pThreads, $pBuffer1, $aResult[1][8] = [[0]]
If (@NumParams) Then
If $iProcessId = -1 Then $iProcessId = @AutoItPid
$iProcessId = ProcessExists($iProcessId)
If Not $iProcessId Then Return SetError(2, 0, $aResult)
EndIf
_RTQuerySystemInformation(5, 0, 0)
If (@Extended = 0) Then Return SetError(@error, 0, $aResult)
$pBuffer = _RTHeapAlloc(@Extended)
If _RTQuerySystemInformation(5, $pBuffer, @Extended) = False Then
Return SetError(@error, _RTHeapFree($pBuffer), $aResult)
EndIf
$pBuffer1 = $pBuffer
If @NumParams Then
While 1
$iOffset = _RTReadBytes($pBuffer)
If _RTReadBytes($pBuffer + 68) <> $iProcessId Then
If ($iOffset) Then
$pBuffer += $iOffset
ContinueLoop
Else
ExitLoop
EndIf
EndIf
$aResult[0][0] = _RTReadBytes($pBuffer + 4)
$pThreads = $pBuffer + 184
Redim $aResult[$aResult[0][0] + 1][8]
For $i = 1 To $aResult[0][0]
$aResult[$i][0] = _RTReadBytes($pThreads + ($i - 1) * 64 + 36); ThreadId
$aResult[$i][1] = $iProcessId ; ProcessId
$aResult[$i][2] = _RTReadBytes($pThreads + ($i - 1) * 64 + 40); Priority
$aResult[$i][3] = _RTReadBytes($pThreads + ($i - 1) * 64 + 44); BPriority
$aResult[$i][4] = _RTReadBytes($pThreads + ($i - 1) * 64 + 28, "ptr")
$aResult[$i][5] = _RTReadBytes($pThreads + ($i - 1) * 64 + 48); CSwitch
$aResult[$i][6] = _RTReadBytes($pThreads + ($i - 1) * 64 + 52); State
$aResult[$i][7] = _RTReadBytes($pThreads + ($i - 1) * 64 + 56); Reason
Next
ExitLoop
WEnd
Else
Local $iPrevIndex = 1
While 1
$iOffset = _RTReadBytes($pBuffer)
$aResult[0][0] += _RTReadBytes($pBuffer + 4)
$pThreads = $pBuffer + 184
Redim $aResult[$aResult[0][0] + 1][8]
For $i = $iPrevIndex To $aResult[0][0]
$aResult[$i][0] = _RTReadBytes($pThreads + ($i - $iPrevIndex) * 64 + 36)
$aResult[$i][1] = _RTReadBytes($pThreads + ($i - $iPrevIndex) * 64 + 32)
$aResult[$i][2] = _RTReadBytes($pThreads + ($i - $iPrevIndex) * 64 + 40)
$aResult[$i][3] = _RTReadBytes($pThreads + ($i - $iPrevIndex) * 64 + 44)
$aResult[$i][4] = _RTReadBytes($pThreads + ($i - $iPrevIndex) * 64 + 28, "ptr")
$aResult[$i][5] = _RTReadBytes($pThreads + ($i - $iPrevIndex) * 64 + 48)
$aResult[$i][6] = _RTReadBytes($pThreads + ($i - $iPrevIndex) * 64 + 52)
$aResult[$i][7] = _RTReadBytes($pThreads + ($i - $iPrevIndex) * 64 + 56)
Next
If ($iOffset = 0) Then ExitLoop
$pBuffer += $iOffset
$iPrevIndex = $aResult[0][0] + 1
WEnd
EndIf
Return SetError(0, _RTHeapFree($pBuffer1), $aResult)
EndFunc ;==>_RTEnumerateThreads
|