复制对象句柄
#include <WinAPI.au3>
_WinAPI_DuplicateHandle($hSourceProcessHandle, $hSourceHandle, $hTargetProcessHandle, $iDesiredAccess, $fInheritHandle, $iOptions)
$hSourceProcessHandle | 句柄将被复制的进程的句柄. |
$hSourceHandle | 将被复制的句柄. |
$hTargetProcessHandle | 用于接收复制句柄的进程句柄. |
$iDesiredAccess | 新句柄所需的访问权限 |
$fInheritHandle | A variable that indicates whether the handle is inheritable |
$iOptions | 可选操作 |
成功: | 返回复制的句柄. |
失败: | 返回 0 |
在MSDN中搜索
#include <WinAPI.au3>
Local $hCurProcessPseudo = _WinAPI_GetCurrentProcess()
ConsoleWrite("Pseudo handle for current process = " & $hCurProcessPseudo & @CRLF)
Local $hCurProcess = _WinAPI_DuplicateHandle($hCurProcessPseudo, $hCurProcessPseudo, $hCurProcessPseudo, Default, True, $DUPLICATE_SAME_ACCESS)
ConsoleWrite("Real handle for current process = " & $hCurProcess & @CRLF)
;...
; Close handle when no longer needed
_WinAPI_CloseHandle($hCurProcess)