Click or drag to resize

FWrite3 Function

X#
Write the contents of a buffer to an open file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION FWrite3(
	ptrHandle AS IntPtr,
	ptrBuffer AS IntPtr,
	dwBytes AS DWORD
) AS DWORD
Request Example View Source

Parameters

ptrHandle
Type: IntPtr
The handle of the file to write to.
ptrBuffer
Type: IntPtr
A pointer to the buffer to write.
dwBytes
Type: DWord
The number of bytes in ptrBuffer to write, beginning at the current file pointer position.

Return Value

Type: DWord
The number of bytes written.
If the value returned is equal to dwBytes, the operation was successful.
If the return value is less than dwBytes or 0, this means that the length of ptrBuffer is less than dwBytes, or the disk is full, or another error has occurred. FError() can be used to determine the specific error.
Remarks
FWrite3() is a strongly-typed version of FWrite(). Moreover, the second argument in FWrite3() is a pointer to a buffer, instead of a string. See FWrite() for details.
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 writes the contents of a PSZ to a file:.
X#
1LOCAL pszBuff AS PSZ
2LOCAL ptrHandle AS PTR
3pszBuff := "hello" // psz converted data
4ptrHandle := FOpen2("temp.bin", FO_READWRITE)
5IF ptrHandle != F_ERROR
6    FWrite3(ptrHandle, pszBuff, PszLen(pszBuff)
7ENDIF
See Also