en:docs:mvm:api:0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en:docs:mvm:api:0 [2024/11/07 05:34] prokusheven:docs:mvm:api:0 [2026/03/20 03:14] (current) prokushev
Line 1: Line 1:
-====== ======+====== 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 ===== ===== Brief =====
 +
 +Duplicate file handle (INT 21h AH=45h)
  
 ===== Input ===== ===== Input =====
  
-  * BX = file handle+  * BX = existing file handle
  
 ===== Return ===== ===== Return =====
Line 12: Line 16:
     * AX = new handle     * AX = new handle
   * CF set on error   * CF set on error
-    * AX = [[en:docs:mvm:api:errors|error code]] (04h,06h) (too many open files (no handles available), invalid handle)+    * AX = [[en:docs:mvm:api:errors|error code]] (04h, 06h)
  
 ===== Notes ===== ===== Notes =====
  
-moving file pointer for either handle will also move it for the other, because both will refer to the same system file table+  * 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 ==== 
 + 
 +<code asm> 
 +include macrolib.inc 
 + 
 +    mov bx, handle 
 +    @SvcDupHandle 
 + 
 +handle dw 1234h 
 +</code> 
 + 
 +==== C ==== 
 + 
 +<code c> 
 +#include <svc.h> 
 + 
 +unsigned short newhandle; 
 +unsigned short oldhandle = 0x1234; 
 + 
 +newhandle = SvcDupHandle(oldhandle); 
 +</code> 
 + 
 +The underlying pragma is defined as: 
 + 
 +<code c> 
 +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]; 
 +</code>
  
 ===== See also ===== ===== See also =====
 +
 +  * [[en:docs:dos:api:int21:45|INT 21h AH=45h]] – DOS duplicate handle
  
 {{page>en:templates:svcapi}} {{page>en:templates:svcapi}}