Kernel32DuplicateHandle(IntPtr, IntPtr, IntPtr, IntPtr, UInt32, Boolean, DuplicateHandleOptions) Method
Duplicates an object handle.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", SetLastError = true)]
public static bool DuplicateHandle(
IntPtr srcProcHandle,
IntPtr srcHandle,
IntPtr dstProcHandle,
ref IntPtr refDstHandle,
uint desiredAccess,
bool inheritHandle,
DuplicateHandleOptions options
)
<DllImportAttribute("Kernel32.dll", SetLastError := true>]
Public Shared Function DuplicateHandle (
srcProcHandle As IntPtr,
srcHandle As IntPtr,
dstProcHandle As IntPtr,
ByRef refDstHandle As IntPtr,
desiredAccess As UInteger,
inheritHandle As Boolean,
options As DuplicateHandleOptions
) As Boolean
Dim srcProcHandle As IntPtr
Dim srcHandle As IntPtr
Dim dstProcHandle As IntPtr
Dim refDstHandle As IntPtr
Dim desiredAccess As UInteger
Dim inheritHandle As Boolean
Dim options As DuplicateHandleOptions
Dim returnValue As Boolean
returnValue = Kernel32.DuplicateHandle(srcProcHandle,
srcHandle, dstProcHandle, refDstHandle,
desiredAccess, inheritHandle, options)
public:
[DllImportAttribute(L"Kernel32.dll", SetLastError = true)]
static bool DuplicateHandle(
IntPtr srcProcHandle,
IntPtr srcHandle,
IntPtr dstProcHandle,
IntPtr% refDstHandle,
unsigned int desiredAccess,
bool inheritHandle,
DuplicateHandleOptions options
)
[<DllImportAttribute("Kernel32.dll", SetLastError = true)>]
static member DuplicateHandle :
srcProcHandle : IntPtr *
srcHandle : IntPtr *
dstProcHandle : IntPtr *
refDstHandle : IntPtr byref *
desiredAccess : uint32 *
inheritHandle : bool *
options : DuplicateHandleOptions -> bool
No code example is currently available or this language may not be supported.
- srcProcHandle IntPtr
-
A handle to the process with the handle to be duplicated.
The handle must have the DuplicateHandle access right.
- srcHandle IntPtr
-
The handle to be duplicated.
This is an open object handle that is valid in the context of the source process.
- dstProcHandle IntPtr
-
A handle to the process that is to receive the duplicated handle.
The handle must have the DuplicateHandle access right.
- refDstHandle IntPtr
-
A pointer to a variable that receives the duplicate handle.
This handle value is valid in the context of the target process.
If srcHandle is a pseudo handle returned by GetCurrentProcess or GetCurrentThread,
DuplicateHandle(IntPtr, IntPtr, IntPtr, IntPtr, GenericAccessRights, Boolean, DuplicateHandleOptions) converts it to a real handle to a process or thread, respectively.
If refDstHandle is Zero,
the function duplicates the handle, but does not return the duplicate handle value to the caller.
This behavior exists only for backward compatibility with previous versions of this function.
You should not use this feature, as you will lose system resources until the target process terminates.
- desiredAccess UInt32
-
The access requested for the new handle.
- inheritHandle Boolean
-
A variable that indicates whether the handle is inheritable.
If , the duplicate handle can be inherited by new processes created by the
target process.
If , the new handle cannot be inherited.
- options DuplicateHandleOptions
-
Optional actions. This parameter can be zero.
Boolean
If the function succeeds, the return value is
.
If the function fails, the return value is
.
To get extended error information, call
GetLastWin32Error.