unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    ldeBudget: TLabeledEdit;
    ldeBills: TLabeledEdit;
    ldeEstimate: TLabeledEdit;
    btnWrite: TButton;
    btnRead: TButton;
    Label1: TLabel;
    procedure btnWriteClick(Sender: TObject);
    procedure btnReadClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
  DogAddr: integer;
  DogBytes: integer;
  DogData: ^byte;

function WriteDog: LongInt; external;
function ReadDog: LongInt; external;
{$L rgdlw32d.obj}


procedure TForm1.btnWriteClick(Sender: TObject);
var
  iBillsCount, iBudgetCount, iEstimateCount: Integer;
  arrData: array [0..2] of Byte;
begin
  try
    iBudgetCount := StrToInt(ldeBudget.Text);  
    iBillsCount := StrToInt(ldeBills.Text);
    iEstimateCount := StrToInt(ldeEstimate.Text);
  except
    Exit;
  end;

  arrData[0] := iBillsCount;
  arrData[1] := iBudgetCount;
  arrData[2] := iEstimateCount;

  DogAddr := $52;
  DogBytes := Length(arrData);
  DogData := @arrData;
  if WriteDog <> 0 then ShowMessage('写狗失败！');
end;

procedure TForm1.btnReadClick(Sender: TObject);
var
  arrData: array [0..2] of Byte;
begin

  DogAddr := $52;
  DogBytes := Length(arrData);
  DogData := @arrData;
  if ReadDog = 0 then
  begin
    ldeBills.Text := IntToStr(arrData[0]);
    ldeBudget.Text := IntToStr(arrData[1]);
    ldeEstimate.Text := IntToStr(arrData[2]);
  end
  else ShowMessage('读狗失败！');
end;

end.
