Falcon4ever
Plugin coder / Betatester
Hi,
I've a problem with my delphi program but i just can't find out what's wrong.
The program must read the filesize in bytes and put that number in nSize (and that works) but it won't do nSize - 4 for some strange reason.
Bytesreken and toread2 need to be nSize - 4
I've a problem with my delphi program but i just can't find out what's wrong.
The program must read the filesize in bytes and put that number in nSize (and that works) but it won't do nSize - 4 for some strange reason.
Bytesreken and toread2 need to be nSize - 4
Code:
FileHandle: THandle;
Buffer1: array[0..3] of Char; // create array for 1st 4 bytes
Buffer2: array of Char; //create changeble array
toread2:longword;
nSize: Integer;
strSize: String;
Bytesreken: Integer;
.
. (more var's but otherwise the list would be to big)
begin
FileHandle := CreateFile(Pchar(Label1.caption),GENERIC_READ,FILE_SHARE_READ,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL + FILE_FLAG_RANDOM_ACCESS, 0);
try
//Get filesize in bytes
nSize := GetFileSize (FileHandle, nil);
SetLength (strSize, 20);
Str (nSize, strSize);
//The math part, filesize (in bytes) - 4 (bytes)
Bytesreken:= nSize-4;
toread2:= nSize-4;
SetLength(Buffer2, Bytesreken); //Bytesreken must be integer Buffer 2 must be filesize - 4
.
.