en:docs:fapi:dosclose

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
en:docs:fapi:dosclose [2018/08/26 13:50] prokusheven:docs:fapi:dosclose [2018/09/02 02:50] prokushev
Line 1: Line 1:
 {{logos:os2.gif?35x35}} {{logos:dos.gif?35x35}} {{logos:os2.gif?35x35}} {{logos:dos.gif?35x35}}
 +
 ====== DosClose ====== ====== DosClose ======
  
Line 5: Line 6:
  
 ==Syntax== ==Syntax==
- DosClose (FileHandle)+ 
 +  DosClose (FileHandle)
  
 ==Parameters== ==Parameters==
-;FileHandle (HFILE) - input : Handle returned by a previous DosOpen, DosMakeNmPipe, or DosMakePipe call.+ 
 +  * FileHandle (HFILE) - input : Handle returned by a previous DosOpen, DosMakeNmPipe, or DosMakePipe call.
  
 ==Return Code== ==Return Code==
- rc (USHORT) - return+ 
 +  rc (USHORT) - return 
 Return code descriptions are: Return code descriptions are:
-* 0        NO_ERROR  + 
-* 2        ERROR_FILE_NOT_FOUND +  * 0        NO_ERROR  
-* 5        ERROR_ACCESS_DENIED +  * 2        ERROR_FILE_NOT_FOUND 
-* 6        ERROR_INVALID_HANDLE+  * 5        ERROR_ACCESS_DENIED 
 +  * 6        ERROR_INVALID_HANDLE
  
 ==Remarks== ==Remarks==
 +
 Issuing DosClose with the handle to a file closes a handle to a file, pipe, or device. Issuing DosClose with the handle to a file closes a handle to a file, pipe, or device.
  
Line 26: Line 33:
  
 ===Named Pipe Considerations=== ===Named Pipe Considerations===
 +
 DosClose closes a named pipe by handle. When all handles referencing one end of a pipe are closed, the pipe is considered broken. DosClose closes a named pipe by handle. When all handles referencing one end of a pipe are closed, the pipe is considered broken.
  
Line 34: Line 42:
 ==Example Code== ==Example Code==
 ===C Binding=== ===C Binding===
-<PRE> 
-#define INCL_DOSFILEMGR 
  
-USHORT  rc = DosClose(FileHandle);+  #define INCL_DOSFILEMGR 
 +   
 +  USHORT  rc = DosClose(FileHandle); 
 +   
 +  HFILE            FileHandle;    /* File handle */ 
 +  USHORT           rc;            /* return code */
  
-HFILE            FileHandle;    /* File handle */ 
-USHORT           rc;            /* return code */ 
-</PRE> 
 This example opens a file, then closes it.  This example opens a file, then closes it. 
-<PRE> 
-#define INCL_DOSFILEMGR 
  
-#define OPEN_FILE 0x01 +  #define INCL_DOSFILEMGR 
-#define CREATE_FILE 0x10 +   
-#define FILE_ARCHIVE 0x20 +  #define OPEN_FILE 0x01 
-#define FILE_EXISTS OPEN_FILE +  #define CREATE_FILE 0x10 
-#define FILE_NOEXISTS CREATE_FILE +  #define FILE_ARCHIVE 0x20 
-#define DASD_FLAG 0 +  #define FILE_EXISTS OPEN_FILE 
-#define INHERIT 0x80 +  #define FILE_NOEXISTS CREATE_FILE 
-#define WRITE_THRU 0 +  #define DASD_FLAG 0 
-#define FAIL_FLAG 0 +  #define INHERIT 0x80 
-#define SHARE_FLAG 0x10 +  #define WRITE_THRU 0 
-#define ACCESS_FLAG 0x02 +  #define FAIL_FLAG 0 
- +  #define SHARE_FLAG 0x10 
-#define FILE_NAME "test.dat" +  #define ACCESS_FLAG 0x02 
-#define FILE_SIZE 800L +   
-#define FILE_ATTRIBUTE FILE_ARCHIVE +  #define FILE_NAME "test.dat" 
-#define RESERVED 0L +  #define FILE_SIZE 800L 
- +  #define FILE_ATTRIBUTE FILE_ARCHIVE 
-HFILE   FileHandle; +  #define RESERVED 0L 
-USHORT  Wrote; +   
-USHORT  Action; +  HFILE   FileHandle; 
-PSZ     FileData[100]; +  USHORT  Wrote; 
-USHORT  rc;+  USHORT  Action; 
 +  PSZ     FileData[100]; 
 +  USHORT  rc;
  
    Action = 2;    Action = 2;
Line 82: Line 90:
                 RESERVED))               /* Reserved (must be zero) */                 RESERVED))               /* Reserved (must be zero) */
       rc = DosClose(FileHandle);         /* File Handle */       rc = DosClose(FileHandle);         /* File Handle */
-</PRE> 
  
 ===MASM Binding=== ===MASM Binding===
-<PRE> 
-EXTRN  DosClose:FAR 
-INCL_DOSFILEMGR     EQU 1 
- 
-PUSH   WORD    FileHandle    ;File handle 
-CALL   DosClose 
  
 +  EXTRN  DosClose:FAR
 +  INCL_DOSFILEMGR     EQU 1
 +  
 +  PUSH   WORD    FileHandle    ;File handle
 +  CALL   DosClose
 +  
 Returns WORD Returns WORD
-</PRE> 
  
 ====== Note ====== ====== Note ======