_lclose

2.x

  HFILE _lclose(hf)    
  HFILE hf; /* handle of file to close */

The _lclose function closes the given file. As a result, the file is no longer available for reading or writing.

Parameters

hf

Identifies the file to be closed. This handle is returned by the function that created or last opened the file.

Return Value

The return value is zero if the function is successful. Otherwise, it is HFILE_ERROR.

Example

The following example copies a file to a temporary file, then closes both files:

int cbRead;
PBYTE pbBuf;

/* Allocate a buffer for file I/O. */

pbBuf = (PBYTE) LocalAlloc(LMEM_FIXED, 2048);

/* Copy the input file to the temporary file. */

do {
    cbRead = _lread(hfReadFile, pbBuf, 2048);
    _lwrite(hfTempFile, pbBuf, cbRead);
} while (cbRead != 0);

/* Free the buffer and close the files. */
LocalFree((HLOCAL) pbBuf);

_lclose(hfReadFile);
_lclose(hfTempFile);

See Also

_lopen, OpenFile