function PrepareBuffer(RequiredSize : integer) : array of byte; stdcall; export;
var
DataBuf : array [0..RequiredSize-1] of byte;
begin
// Make the buffer equal in size to the file that is about to be read
FillChar(DataBuf, RequiredSize, #00);
result := DataBuf;
end;
function MainFunc....
var
DataBuf : array of byte; // How do I declare the array size to be whatever size is later needed by the total bytes read in the file?
begin
...
ItemSize := APICall_GetItemSize(Item); // Get the file size of the specified file item
DataBuf := PrepareBuffer(ItemSize); // Prepare the buffer to be equal in size for the file about to be read
intBytesRead := APICall_Read(Item, 0, @DataBuf, ItemSize); // Read the file data into the buffer
...