unit1.pas

来自「CRC 计算」· PAS 代码 · 共 70 行

PAS
70
字号
unit Unit1;

interface

uses
  SysUtils, WinTypes, WinProcs, Classes, Controls,
  Forms, Dialogs, StdCtrls, Buttons, CRC;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    BitBtn1: TBitBtn;
    Label3: TLabel;
    OpenDialog: TOpenDialog;
    Label4: TLabel;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  f: File;
  CRC16: Word;
  CRC32: LongInt;
  CRCArc: Word;

 procedure Error;
 begin
   Application.MessageBox('Open error.', 'I/O Error', mb_Ok or mb_IconStop)
 end;

begin
  if OpenDialog.Execute then
   begin
    if not FileCRC16(OpenDialog.FileName, CRC16) then
     begin
      Error;
      Exit;
     end;
    Label1.Caption := 'CRC16 = ' + IntToStr(CRC16);

    if not FileCRC32(OpenDialog.FileName, CRC32) then
     begin
      Error;
      Exit;
     end;
    Label2.Caption := 'CRC32 = ' + IntToStr(CRC32);

    if not FileCRCArc(OpenDialog.FileName, CRCArc) then
     begin
      Error;
      Exit;
     end;
    Label4.Caption := 'CRCArc = ' + IntToStr(CRCArc);
   end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?