函数参考


_WinAPI_DuplicateHandle

复制对象句柄

#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

注意/说明


相关

_WinAPI_OpenProcess, _WinAPI_CloseHandle

详情参考

在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)