Reads a portion of a file into a binary buffer.
BinaryReadEx( handle, binary-offset, filename, file-offset, count )
(i) handle: handle of buffer.
(i) binary-offset: zero-based offset into the buffer specifying where the data should be stored. This parameter accepts a 64-bit integer data type.
(i) filename: file to read into buffer.
(t) file-offset: zero-based offset into the file specifying where the data to be read starts. This parameter accepts a huge number or a 64-bit integer data type.
(i) count: the number of bytes to read.
(i) Returns the number of bytes read.
This function reads "count" bytes from "filename", beginning at "file-offset". It then writes the data to the buffer specified by "handle", beginning at "binary-offset". Any existing data in the buffer within the range "binary-offset + count" is overwritten with the new data; any existing data outside that range is left untouched.
If "file-offset" + "count" is larger than the file size, or if "count" is -1, "count" will be ignored and it will be treated as a request to read from "file-offset" to the end of the file.
file-offset
BinaryReadEx and BinaryWriteEx accept a huge number or 64-bit integer for the "file-offset". A huge number is a long decimal number string, which may represent a number too large to be converted to an integer.
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 read more than 2GBs at a time. When using 64-bit WinBatch larger files can be read into a single buffer by adjusting the buffer and file offsets between multiple calls to the function.
file = "hello.txt" buf = BinaryAlloc(100) BinaryPokeStr(buf, 0, "12345") rc = BinaryReadEx(buf, 2, file, 4, 1) Message("BinaryReadEx returned", rc) eod = BinaryEodGet(buf) Message("BinaryEod is", eod) STRING = BinaryPeekStr(buf, 0, eod) Message("BinaryPeekStr returned", STRING)
IntControl 39, Binary Operations, BinaryRead, BinaryAlloc, BinaryFree, BinaryWrite, BinaryWriteEx, ChrStringToUnicode