ReadBytes

InstallShield 2020 ยป InstallScript Language Reference

The ReadBytes function reads a specific number of bytes from a file starting at the current file pointer location. When this function returns, InstallShield relocates the file pointer to the new position at the end of the bytes read from the file.

Note:Before you can read from the file, which may be a file on the Internet, you must open the file in binary mode by calling OpenFileMode and OpenFile.

The parameter nIndex is an index into the value specified by svString. Use the parameter nBytes to specify how many bytes beyond the parameter nIndex to read from the file. If the nIndex plus nBytes is a value larger than the length of the svString, only the number of bytes from the index of the string to the end of the string are read from the file. For example, if svString is declared to be 100 bytes long, the parameter nIndex is declared as 50 bytes and the parameter nBytes is 75 bytes, only the bytes between 49 and 99 (50 bytes instead of 75 bytes) are read.

Syntax

ReadBytes ( nFileHandle, svString, nIndex, nBytes );

Parameters

ReadBytes Parameters

Parameter

Description

nFileHandle

Specifies the file handle to a file opened in binary mode.

svString

Returns the bytes read from the file. The variable passed in this parameter must have been declared with an explicit size, and it must be large enough to accommodate the number of bytes specified by nBytes.

nIndex

Specifies an index into svString; data from the file is inserted into the string at this location.

nBytes

Specifies the number of bytes to read from the file. Bytes are read starting from the current location of the file pointer. InstallShield relocates the file pointer as the bytes are read.

Return Values

ReadBytes Return Values

Return Value

Description

X

Indicates that the function successfully read bytes from the file, where X is the actual number of bytes returned in svString.

< 0

Indicates that the function was unable to successfully read from the file.

See Also