Функция _WinAPI_DuplicateHandle

 ↑  ←  Описание функции


_WinAPI_DuplicateHandle

Дублирует дескриптор объекта

#include <WinAPI.au3>
_WinAPI_DuplicateHandle($hSourceProcessHandle, $hSourceHandle, $hTargetProcessHandle, $iDesiredAccess, $fInheritHandle, $iOptions)

Параметры

$hSourceProcessHandle A handle to the process with the handle to be duplicated
$hSourceHandle The handle to be duplicated
$hTargetProcessHandle A handle to the process that is to receive the duplicated handle
$iDesiredAccess The access requested for the new handle
$fInheritHandle A variable that indicates whether the handle is inheritable
$iOptions Optional actions

Возвращаемое значение

Успех:Возвращает новый дескриптор
Ошибка:Возвращает 0

См. также

_WinAPI_OpenProcess, _WinAPI_CloseHandle

См. также

Искать DuplicateHandle в библиотеке 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)