Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
DosClose (1.2)
◄Function Group► ◄Overview► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
#define INCL_DOSFILEMGR
USHORT DosClose(hf)
HFILE hf; /* file handle */
The DosClose function closes a specified file or pipe.
The DosClose function is a family API function.
Parameter Description
────────────────────────────────────────────────────────────────────────────
hf Identifies the file to close. This handle must have been created
by using the DosOpen, DosDupHandle, or DosMakePipe function.
Return Value
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be one of the following:
ERROR_ACCESS_DENIED
ERROR_FILE_NOT_FOUND
ERROR_INVALID_HANDLE
Comments
When all handles referencing one end of a pipe are closed, the pipe is
considered "broken." If the client end closes, no other process can reopen
the pipe until the server end issues a DosDisConnectNmPipe function followed
by a DosConnectNmPipe function. If the server end closes, the pipe will be
deallocated when the last client handle is closed, or it will be deallocated
immediately if the pipe is already broken.
If the file was opened with the OPEN_FLAGS_WRITE_THRU flag set, then
DosClose will cause the system to write the contents of all the file's
internal buffers to the device──for example, to the disk──and to update all
directory information prior to returning.
Example
This example opens the file abc, reads from the file, and calls the
DosClose function to close it:
BYTE abBuf[512];
HFILE hf;
USHORT usAction, cbBytesRead;
DosOpen("abc", &hf, &usAction, 0L, FILE_NORMAL, FILE_OPEN,
OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0L);
DosRead(hf, abBuf, sizeof(abBuf), &cbBytesRead);
DosClose(hf); /* closes the file */
See Also
DosBufReset, DosConnectNmPipe, DosDisConnectNmPipe, DosDupHandle,
DosFindClose, DosMakePipe, DosOpen, DosRead
♦