|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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 Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
||||
|
||||
|
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.
|
|
#5
|
|||
|
|||
|
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;
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > Making a patcher/auto updater |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|