en:docs:fapi:dosduphandle

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:docs:fapi:dosduphandle [2018/09/02 04:59] prokusheven:docs:fapi:dosduphandle [2021/12/05 09:55] (current) prokushev
Line 1: Line 1:
-{{logos:os2.gif?35x35}} {{logos:dos.gif?35x35}}+{{page>en:templates:fapiint}} 
 ====== DosDupHandle ====== ====== DosDupHandle ======
  
 This call returns a new file handle for an open file, which refers to the same position in the file as the old file handle. This call returns a new file handle for an open file, which refers to the same position in the file as the old file handle.
  
-==Syntax==+===== Syntax ===== 
 + 
 +<code c> 
 +DosDupHandle (OldFileHandle, NewFileHandle) 
 +</code>
  
-  DosDupHandle (OldFileHandle, NewFileHandle)+===== Parameters =====
  
-==Parameters== 
  
-  *OldFileHandle (HFILE) - input : Current file handle. +  *OldFileHandle ([[HFILE]]) - input : Current file handle. 
-  *NewFileHandle (PHFILE) - input/output : Address of a Word. On input, values and their meanings are:+  *NewFileHandle ([[PHFILE]]) - input/output : Address of a Word. On input, values and their meanings are:
     *FFFFH - Allocate a new file handle and return it here.     *FFFFH - Allocate a new file handle and return it here.
     *<>FFFFH - Assign this value as the new file handle. A valid value is any of the handles assigned to standard I/O, or the handle of a file currently opened by the process.     *<>FFFFH - Assign this value as the new file handle. A valid value is any of the handles assigned to standard I/O, or the handle of a file currently opened by the process.
   *On output, a value of FFFFH returns a value for NewFileHandle, allocated by OS/2.   *On output, a value of FFFFH returns a value for NewFileHandle, allocated by OS/2.
  
-==Return Code==+===== Return Code =====
  
-  rc (USHORT) - return+rc ([[USHORT]]) - return
      
 Return code descriptions are: Return code descriptions are:
Line 27: Line 31:
   * 114      ERROR_INVALID_TARGET_HANDLE   * 114      ERROR_INVALID_TARGET_HANDLE
  
-==Remarks==+===== Remarks =====
  
-Duplicating the handle duplicates and ties all handle-specific information between OldFileHandle and NewFileHandle. For example, if you move the read/write pointer of either handle by a DosRead, DosWrite, or DosChgFilePtr function call, the pointer for the other handle is also changed.+ 
 +Duplicating the handle duplicates and ties all handle-specific information between OldFileHandle and NewFileHandle. For example, if you move the read/write pointer of either handle by a [[DosRead]][[DosWrite]], or [[DosChgFilePtr]] function call, the pointer for the other handle is also changed.
  
 The valid values for NewFileHandle include the following handles for standard I/O, which are always available to the process: The valid values for NewFileHandle include the following handles for standard I/O, which are always available to the process:
Line 39: Line 44:
 If a file handle value of a currently open file is specified in NewFileHandle, the file handle is closed before it is redefined as the duplicate of OldFileHandle. Avoid using arbitrary values for NewFileHandle. If a file handle value of a currently open file is specified in NewFileHandle, the file handle is closed before it is redefined as the duplicate of OldFileHandle. Avoid using arbitrary values for NewFileHandle.
  
-Issuing a DosClose against a file handle does not affect the duplicate handle.+Issuing a [[DosClose]] against a file handle does not affect the duplicate handle.
  
-==Example Code== +===== Example Code =====
-===C Binding===+
  
 +==== C Binding ====
 +
 +<code c>
   #define INCL_DOSFILEMGR   #define INCL_DOSFILEMGR
      
Line 52: Line 59:
      
   USHORT           rc;            /* return code */   USHORT           rc;            /* return code */
 +</code>
  
 This example opens a file, creates a second file handle, then closes the file with the second handle.  This example opens a file, creates a second file handle, then closes the file with the second handle. 
  
 +<code c>
   #define INCL_DOSFILEMGR   #define INCL_DOSFILEMGR
      
Line 97: Line 106:
                         &NewHandle);     /* New file handle */                         &NewHandle);     /* New file handle */
  
-===MASM Binding===+</code> 
 + 
 +==== MASM Binding ===
  
   EXTRN  DosDupHandle:FAR   EXTRN  DosDupHandle:FAR
Line 108: Line 120:
 Returns WORD Returns WORD
  
-====== Note ======+===== Note ===== 
  
 Text based on [[http://www.edm2.com/index.php/DosDupHandle_(FAPI)]] Text based on [[http://www.edm2.com/index.php/DosDupHandle_(FAPI)]]