====== SVC_DUPHANDLE ======
Duplicate a file handle. This call creates a new file handle that refers to the same open file, pipe, or device as an existing handle.
===== Brief =====
Duplicate file handle (INT 21h AH=45h)
===== Input =====
* BX = existing file handle
===== Return =====
* CF clear if successful
* AX = new handle
* CF set on error
* AX = [[en:docs:mvm:api:errors|error code]] (04h, 06h)
===== Notes =====
* Both handles refer to the same system file table entry. Moving the file pointer for one handle also moves it for the other.
* Closing one handle does not affect the other until both are closed.
* The new handle has the same access rights and sharing mode as the original.
===== Binding =====
==== MASM ====
include macrolib.inc
mov bx, handle
@SvcDupHandle
handle dw 1234h
==== C ====
#include
unsigned short newhandle;
unsigned short oldhandle = 0x1234;
newhandle = SvcDupHandle(oldhandle);
The underlying pragma is defined as:
extern unsigned short SvcDupHandle(unsigned short handle);
#pragma aux SvcDupHandle = \
"hlt" \
"db 0" \
"db NOT 0" \
parm [bx] \
value [ax] \
modify [ax bx cx dx];
===== See also =====
* [[en:docs:dos:api:int21:45|INT 21h AH=45h]] – DOS duplicate handle
{{page>en:templates:svcapi}}