Writes a binary buffer to a file.
BinaryWrite( handle, filename )
(i) handle: handle of buffer.
(s) filename: filename to write buffer to.
(i) number of bytes written.
This function writes the contents of a binary buffer out to a file and returns the number of bytes written. Data written to the file starts at offset 0 in the buffer and extends to the end of data - not necessarily the end of the buffer. The end of data may be inspected or modified with the BinaryEodGet and BinaryEodSet functions.
This function supports extended-length path but requires the extended-length file paths to be converted to a Unicode string before being passed to the function. Use ChrStringToUnicode to do the conversion.
Note: Because Windows system limitations this function cannot write binary buffers larger than 2GBs regardless of the buffer size.
; This example edits the Config.sys file by adding a line ; to the bottom of the file. fs=FileSize("C:\CONFIG.SYS") binbuf = BinaryAlloc(fs+100) If binbuf == 0 Message("Error", "BinaryAlloc Failed") Else BinaryRead(binbuf, "C:\CONFIG.SYS") BinaryPokeStr(binbuf, fs, "DEVICE=C:\FLOOGLE.SYS%@crlf%") BinaryWrite(binbuf, "C:\CONFIG.SYS") binbuf=BinaryFree(binbuf) EndIf Message("BinaryWrite", "Done.")
Binary Operations, IntControl 40, BinaryAlloc, BinaryWriteEx , BinaryFree, BinaryRead, ChrStringToUnicode