Lazarus Pascal
Lazarus Pascal
Compute CRC32 of a File
Calculates the CRC32 of a file's contents and returns the 32-bit CRC as a hex string.Chilkat Lazarus Pascal Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.ZipCrc;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
zipCrc: TZipCrc;
crc: Integer;
hexStr: string;
begin
zipCrc := TZipCrc.Create;
// Use a relative for absolute path to the file..
crc := zipCrc.FileCrc('qa_data/hamlet.xml');
hexStr := zipCrc.ToHex(crc);
WriteLn(hexStr);
zipCrc.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.