UINT _lwrite(hf, hpvBuffer, cbBuffer) | |||||
HFILE hf; | /* file handle | */ | |||
const void _huge* hpvBuffer; | /* address of buffer for write data | */ | |||
UINT cbBuffer; | /* size of data, */ |
The _lwrite function writes data to the specified file.
hf
Identifies the file to be written to.
hpvBuffer
Points to a buffer that contains the data to be written to the file.
cbBuffer
Specifies the number of bytes to be written to the file. If this parameter is zero, the file is expanded or truncated to the current file-pointer position.
The return value indicates the number of bytes written to the file, if the function is successful. Otherwise, the return value is HFILE_ERROR.
The buffer specified by hpvBuffer cannot extend past the end of a segment.
The following example uses the _lread and _lwrite functions to copy data from one file to another:
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);