Enumerates a handles that belong to the specified process.
#Include <WinAPIEx.au3>
_WinAPI_EnumProcessHandles ( [$PID [, $iType ]] )
$PID | [可选参数] The PID of the process. Default (0) is the current process. |
$iType | [可选参数] The value associated with the type of the objects that should be enumerated. This value depends on the operating system. If this parameter is 0, all handles of the specified process will be enumerated. |
Success | The array containing the following information: |
[0][0] | Number of rows in array (n) |
[0][i] | Unused |
[n][0] | Handle |
[n][1] | Type (depends on the operating system) |
[n][2] | Attributes |
[n][3] | Access |
Failure | 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS code. |
在MSDN中搜索
#Include <APIConstants.au3>
#Include <Array.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global Const $PID = @AutoItPID
Global $Data, $hSource, $hTarget, $hObject
$Data = _WinAPI_EnumProcessHandles($PID)
If IsArray($Data) Then
$hTarget = _WinAPI_GetCurrentProcess()
$hSource = _WinAPI_OpenProcess($PROCESS_DUP_HANDLE, 0, $PID)
If $hSource Then
For $i = 1 To $Data[0][0]
$hObject = _WinAPI_DuplicateHandle($hSource, $Data[$i][0], $hTarget)
If Not @error Then
$Data[$i][1] = _WinAPI_GetObjectNameByHandle($hObject)
_WinAPI_CloseHandle($hObject)
EndIf
Next
EndIf
EndIf
_ArrayDisplay($Data, '_WinAPI_EnumProcessHandles')