- Код: Выделить всё
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Memo1: TMemo;
Timer1: TTimer;
Timer2: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
Port: integer;
[color=#FF0000]DCB:tDCB;[/color]
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
Port:=CreateFile(pchar(edit1.Text),
GENERIC_READ or GENERIC_WRITE,0,
nil,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0);
SetupComm(Port,$2000,$2000);
GetCommState(Port,Dcb) then Exit;
Dcb.BaudRate := Cardinal(EntryProps.IntAttr[0]);
Dcb.ByteSize := EntryProps.IntAttr[1];
Dcb.Parity := EntryProps.IntAttr[2];
Dcb.StopBits := EntryProps.IntAttr[3];
SetCommState(Port,Dcb);
PurgeComm(Port,PURGE_TXCLEAR or PURGE_RXCLEAR);
SetCommMask(Port,EV_RXCHAR);
Button2.Enabled:=True;
Button1.Enabled:=False;
Memo1.Lines.Add('Порт открыт!');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
CloseHandle(Port);
Button1.Enabled:=true;
Button2.Enabled:=False;
Memo1.Lines.Add('Порт закрыт!');
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
timer2.Interval:=strtoint(edit4.Text);
Button5.Enabled:=true;
Button4.Enabled:=False;
Timer2.Enabled:=true;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Button4.Enabled:=true;
Button5.Enabled:=False;
Timer2.Enabled:=false;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
end;
initialization
{$I Unit1.lrs}
end.
DCB:tDCB; ругается на этой строчке