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 revision
Previous revision
en:docs:fapi:dosclose [2018/08/26 13:50] prokusheven:docs:fapi:dosclose [2021/12/05 06:37] (current) prokushev
Line 1: Line 1:
-{{logos:os2.gif?35x35}} {{logos:dos.gif?35x35}}+{{page>en:templates:fapiint}} 
 ====== DosClose ====== ====== DosClose ======
  
 This call closes a handle to a file, pipe, or device. This call closes a handle to a file, pipe, or device.
  
-==Syntax== +===== Syntax =====
- DosClose (FileHandle)+
  
-==Parameters== +<code c> 
-;FileHandle (HFILE) - input : Handle returned by a previous DosOpen, DosMakeNmPipe, or DosMakePipe call.+DosClose (FileHandle) 
 +</code> 
 + 
 +===== Parameters ===== 
 + 
 + 
 +  FileHandle ([[HFILE]]) - input : Handle returned by a previous [[DosOpen]][[DosMakeNmPipe]], or [[DosMakePipe]] call. 
 + 
 +===== Return Code ===== 
 + 
 + 
 +rc ([[USHORT]]) - return
  
-==Return Code== 
- rc (USHORT) - return 
 Return code descriptions are: Return code descriptions are:
-* 0        NO_ERROR  
-* 2        ERROR_FILE_NOT_FOUND 
-* 5        ERROR_ACCESS_DENIED 
-* 6        ERROR_INVALID_HANDLE 
  
-==Remarks==+  * 0        NO_ERROR  
 +  * 2        ERROR_FILE_NOT_FOUND 
 +  * 5        ERROR_ACCESS_DENIED 
 +  * 6        ERROR_INVALID_HANDLE 
 + 
 +===== 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.
  
-If one or more additional handles to a file have been created with DosDupHandle, the directory is not updated and all internal buffers are not written to the medium until DosClose has been issued for the duplicated handles.+If one or more additional handles to a file have been created with [[DosDupHandle]], the directory is not updated and all internal buffers are not written to the medium until DosClose has been issued for the duplicated handles.
  
 Closing a handle to a device causes the device to be notified of the close, if appropriate.  Closing a handle to a device causes the device to be notified of the close, if appropriate. 
  
-===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 32: Line 45:
 If the server end closes when the pipe is already broken, it is deallocated immediately; otherwise, the pipe is not deallocated until the last client handle is closed. If the server end closes when the pipe is already broken, it is deallocated immediately; otherwise, the pipe is not deallocated until the last client handle is closed.
  
-==Example Code== +===== Example Code =====
-===C Binding=== +
-<PRE> +
-#define INCL_DOSFILEMGR+
  
-USHORT  rc DosClose(FileHandle);+==== C Binding ====
  
-HFILE            FileHandle;    /* File handle */ +<code c> 
-USHORT           rc;            /* return code */ +  #define INCL_DOSFILEMGR 
-</PRE> +   
-This example opens a file, then closes it.  +  USHORT  rc = DosClose(FileHandle); 
-<PRE> +   
-#define INCL_DOSFILEMGR+  HFILE            FileHandle;    /* File handle */ 
 +  USHORT           rc;            /* return code */ 
 +</code>
  
-#define OPEN_FILE 0x01 +This example opens a file, then closes it.  
-#define CREATE_FILE 0x10 +<code c> 
-#define FILE_ARCHIVE 0x20 +  #define INCL_DOSFILEMGR 
-#define FILE_EXISTS OPEN_FILE +   
-#define FILE_NOEXISTS CREATE_FILE +  #define OPEN_FILE 0x01 
-#define DASD_FLAG 0 +  #define CREATE_FILE 0x10 
-#define INHERIT 0x80 +  #define FILE_ARCHIVE 0x20 
-#define WRITE_THRU 0 +  #define FILE_EXISTS OPEN_FILE 
-#define FAIL_FLAG 0 +  #define FILE_NOEXISTS CREATE_FILE 
-#define SHARE_FLAG 0x10 +  #define DASD_FLAG 0 
-#define ACCESS_FLAG 0x02 +  #define INHERIT 0x80 
- +  #define WRITE_THRU 0 
-#define FILE_NAME "test.dat" +  #define FAIL_FLAG 0 
-#define FILE_SIZE 800L +  #define SHARE_FLAG 0x10 
-#define FILE_ATTRIBUTE FILE_ARCHIVE +  #define ACCESS_FLAG 0x02 
-#define RESERVED 0L +   
- +  #define FILE_NAME "test.dat" 
-HFILE   FileHandle; +  #define FILE_SIZE 800L 
-USHORT  Wrote; +  #define FILE_ATTRIBUTE FILE_ARCHIVE 
-USHORT  Action; +  #define RESERVED 0L 
-PSZ     FileData[100]; +   
-USHORT  rc;+  HFILE   FileHandle; 
 +  USHORT  Wrote; 
 +  USHORT  Action; 
 +  PSZ     FileData[100]; 
 +  USHORT  rc;
  
    Action = 2;    Action = 2;
Line 82: Line 98:
                 RESERVED))               /* Reserved (must be zero) */                 RESERVED))               /* Reserved (must be zero) */
       rc = DosClose(FileHandle);         /* File Handle */       rc = DosClose(FileHandle);         /* File Handle */
-</PRE>+</code>
  
-===MASM Binding=== +==== MASM Binding ====
-<PRE> +
-EXTRN  DosClose:FAR +
-INCL_DOSFILEMGR     EQU 1+
  
-PUSH   WORD    FileHandle    ;File handle +<code asm> 
-CALL   DosClose+  EXTRN  DosClose:FAR 
 +  INCL_DOSFILEMGR     EQU 1 
 +   
 +  PUSH   WORD    FileHandle    ;File handle 
 +  CALL   DosClose 
 +</code>  
  
 Returns WORD Returns WORD
-</PRE> 
  
-====== Note ======+===== Note =====
  
 Text based on [[http://www.edm2.com/index.php/DosClose_(FAPI)]] Text based on [[http://www.edm2.com/index.php/DosClose_(FAPI)]]