#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    27
    Rep Power
    0

    Making a patcher/auto updater


    Hello, my friend told me about this site and it looks like by far the best delphi community I've ever found! I would like to make my program able to update itself, and was thinking it would go like this: 1.The program downloads a text file from my website that looks like this "fileName <space> checksum". 2.The program would deliminate by space into a TStringList. 3.The program would check if the file even exists, then if it does exist, compare it to its checksum. 4.If it does not exist or its checksum does not match, its file name would be added to another TStringList (of things to download). These 4 steps would repeat until EOF, then it would download everything that didn't match or did not exist. First off, can anyone see anyway to improve my method or anything wrong with it? Second off, does anyone know a way to get a checksum for a file?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    See http://www.torry.net/pages.php?id=251 for some checksum components. Seems that TFileCheckSumComp even does a reinstall, if the checksum doesn't match .

    Actually, these components may be more useful to you:
    http://www.torry.net/pages.php?id=56

    Note that some of them are free.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    27
    Rep Power
    0
    I think using FileSize might be best, I read something on it and it declared the variable as "File of Word". I've only used TextFile's before, but for potentially large files would FIle of Word be best? And would you guys agree FileSize is better than checksums? I don't want to bog down their comp while its updating.
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    Dunno really. Depends on the situation. I would think Checksums are better because they can handle it if there are bit corruption errors. It doesn't take that long to compute checksums by the way.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    27
    Rep Power
    0
    can't seem to find any good components on the site ya gave me, the one you recommended didn't seem like it'd work since I'm not using installshield. But, does this code seem good? It works extremely fast, and it gives the same checksum for the same file twice (always a plus ) but can anyone see anything wrong with it?
    Code:
    function GetCheckSum(FileName: string): DWORD; 
    var 
      F: file of DWORD; 
      P: Pointer; 
      Fsize: DWORD; 
      Buffer: array [0..500] of DWORD; 
    begin 
      FileMode := 0; 
      AssignFile(F, FileName); 
      Reset(F); 
      Seek(F, FileSize(F) div 2); 
      Fsize := FileSize(F) - 1 - FilePos(F); 
      if Fsize > 500 then Fsize := 500; 
      BlockRead(F, Buffer, Fsize); 
      Close(F); 
      P := @Buffer; 
      asm 
         xor eax, eax 
         xor ecx, ecx 
         mov edi , p 
         @again: 
           add eax, [edi + 4*ecx] 
           inc ecx 
           cmp ecx, fsize 
         jl @again 
         mov @result, eax 
       end; 
    end;

IMN logo majestic logo threadwatch logo seochat tools logo