Results 1 to 3 of 3
  1. #1
    Plugin coder / Betatester Falcon4ever's Avatar
    Join Date
    Mar 2002
    Location
    The Netherlands
    Posts
    1,253

    Unhappy [Delphi] not really an emu question.

    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




    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 
    .
    .


    • Advertising

      advertising
      EmuTalk.net
      has no influence
      on the ads that
      are displayed
        
       

  2. #2
    Moderator icepir8's Avatar
    Join Date
    Nov 2001
    Location
    Everywhere
    Posts
    938
    make nSize and Bytesreken longs.

    "Some people are like Slinkies... not really good for anything, but they still bring a smile to your face when you push them down a flight of stairs." -- author unknown

  3. #3
    Plugin coder / Betatester Falcon4ever's Avatar
    Join Date
    Mar 2002
    Location
    The Netherlands
    Posts
    1,253
    Ok i will try that soon.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •