1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CPortCtl, CPort;
type
TForm1 = class(TForm)
ComPort1: TComPort;
Button1: TButton;
Edit1: TEdit;
Memo1: TMemo;
ComComboBox1: TComComboBox;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure SendCommand(StrCommand: string);
procedure Sendmsg(StrCommand: string);
procedure ComPort1RxChar(Sender: TObject; Count: Integer);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SendCommand(strCommand: string);
var s : string;
begin
s := strCommand+chr(13);
Comport1.WriteStr(s);
end;
procedure TForm1.Sendmsg(strCommand: string);
var s : string;
begin
s := strCommand+chr(26);
Comport1.WriteStr(s);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Sendmsg(edit1.Text);
end;
procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
var
Str: String;
begin
Comport1.ReadStr(Str,count);
memo1.Text:=memo1.Text+str;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
COMPORT1.Open;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
SendCommand('AT+CMGS=,"'+'600'+'",15');
end;
end. |
Partager