Click or drag to resize

FRead3 Function

Read characters from a file into an allocated buffer.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION FRead3(
	ptrHandle AS IntPtr,
	ptrBufferVar AS IntPtr,
	dwBytes AS DWORD
) AS DWORD
View Source

Parameters

ptrHandle
Type: IntPtr
The handle of the file to read from.
ptrBufferVar
Type: IntPtr
Pointer to an allocated buffer used to store data read from the specified file.  The length of this variable must be greater than or equal to <dwBytes>.
dwBytes
Type: UInt32
The number of bytes to read into the buffer.

Return Value

Type: UInt32
The number of bytes successfully read.  A return value less than <dwBytes> or 0 indicates end-of-file or some other read error.  FError() can be used to determine the specific error.
Remarks
FRead3() is the same as FRead(), except that the name of the buffer variable is a pointer and is not passed by reference. See FRead() for details. This function is assumed to handle raw binary data and is not dependent upon the status of SetAnsi().  FReadText() and FRead4(), on the other hand, are dependent upon SetAnsi().
Remarks
Tip Tip
This function is included for compatibility. We do not recomment using static memory for file i/o operations. We recommend that you use the function overload that takes a byte array parameter in stead.
Examples
This example uses FRead3() after successfully opening a file to read 128 bytes into a buffer area:
X#
DEFINE F_BLOCK := 128
Function Start()
        LOCAL cBuffer AS PTR
        cBuffer := MemAlloc(F_BLOCK)
        IF cBuffer = NULL PTR
                RETURN FALSE
        ENDIF
        ptrHandle := FOpen2("temp.txt", FO_READ)
        IF ptrHandle = F_ERROR
                ? DOSErrString(FError())
                RETURN FALSE
        ELSE
                IF FRead3(ptrHandle, cBuffer, F_BLOCK) <> F_BLOCK
                        ? DOSErrString(FError())
                        RETURN FALSE
                ENDIF
                FClose(ptrHandle)
        ENDIF
        MemFree(cBuffer)
        RETURN TRUE
See Also