home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / section5 / fxn46h.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  1.3 KB  |  26 lines

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;          Function 46H: Force Duplicate File Handle         ;
  4.         ;                                                            ;
  5.         ;          int dup_handle2(existhandle,newhandle)            ;
  6.         ;              int existhandle,newhandle;                    ;
  7.         ;                                                            ;
  8.         ;          Returns -1 for errors,                            ;
  9.         ;          otherwise returns newhandle unchanged.            ;
  10.         ;                                                            ;
  11.         ;************************************************************;
  12.  
  13. cProc   dup_handle2,PUBLIC
  14. parmW   existhandle
  15. parmW   newhandle
  16. cBegin
  17.         mov     bx,existhandle  ; Get handle of existing file.
  18.         mov     cx,newhandle    ; Get handle to copy into.
  19.         mov     ah,46h          ; Close handle CX and then
  20.         int     21h             ; duplicate BX's handle into CX.
  21.         mov     ax,newhandle    ; Prepare return value.
  22.         jnb     dup2_ok         ; Branch if close/copy was successful.
  23.         mov     ax,-1           ; Else return -1.
  24. dup2_ok:
  25. cEnd
  26.