具体说明一下如何使用把CRC32值存放在别的文件中和把CRC32值放在不是校验的部份。
procedure GetCRC32File(FileName: string; var CRC32: DWORD);
var
F: file;
BytesRead: DWORD;
Buffer: array[1..65521] of Byte;
i: Word;
begin
FileMode := 0;
CRC32 := $FFFFFFFF;
{$I-}
AssignFile(F, FileName);
Reset(F, 1);
if IoResult = 0 then
begin
repeat
BlockRead(F, Buffer, Sizeof(Buffer), BytesRead);
for i := 1 to BytesRead do
CRC32 := (CRC32 shr 8) xor Table[Buffer[i] xor (CRC32 and
$000000FF)];
until BytesRead = 0;
end;
CloseFile(F);
{$I+}
CRC32 := not CRC32;
end;
function GetCrc32Str(s: string; Seed: LongInt): string;
var
Count: Integer;
CrcVal: LongInt;
begin
CrcVal := Seed;
for Count := 1 to Length(s) do
CrcVal := Table[Byte(CrcVal xor DWORD(Ord(s[Count])))] xor ((CrcVal shr
8) and $00FFFFFF);
Result := IntToHex(not (CrcVal), 8);
end;