unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, MSCommLib_TLB, ExtCtrls;type
TForm1 = class(TForm)
MSComm1: TMSComm;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Timer1: TTimer;
procedure MSComm1Comm(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.MSComm1Comm(Sender: TObject);
begin
Memo1.Lines.Add(inttostr(MsComm1.InputLen)+', '+ MSComm1.Input);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
MSComm1.PortOpen := True;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
MSComm1.PortOpen := False;
end;procedure TForm1.Button3Click(Sender: TObject);
begin
MSComm1.Output := Edit1.Text;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
if MsComm1.PortOpen = true then begin
label2.Caption := inttostr(mscomm1.OutBufferCount);
end;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, MSCommLib_TLB, ExtCtrls;type
TForm1 = class(TForm)
MSComm1: TMSComm;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Timer1: TTimer;
procedure MSComm1Comm(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.MSComm1Comm(Sender: TObject);
begin
Memo1.Lines.Add(inttostr(MsComm1.InputLen)+', '+ MSComm1.Input);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
MSComm1.PortOpen := True;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
MSComm1.PortOpen := False;
end;procedure TForm1.Button3Click(Sender: TObject);
begin
MSComm1.Output := Edit1.Text;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
if MsComm1.PortOpen = true then begin
label2.Caption := inttostr(mscomm1.OutBufferCount);
end;
end;end.
解决方案 »
- 在Delphi中利用线程--解决程序没有计算完之前不能做其它任何事情
- 我们有项目外包!!!!!!!!!!!!!!!!!!
- 问个有难度的问题,高手进来解决!!!
- 請教Delphi中相應字符得到它得ascii碼和ascii碼得到相應得字符,用什麼函數??急,急!
- 请问调用SoapWebservice如何设置proxy?
- 象打游戏那样,鼠标到达屏幕右边上,图往坐移动,到上往下移动
- 如何配置IDE环境?
- 关于ACCESS数据库的时间查询问题
- 用已下程序将数据写入注册表,问怎么把程序写入的数据读到EDIT1控件中?
- 各位,这段程序编译时报告最后一行(end.)出错
- 怎样判断一个类是否已被实例化过?
- 大侠给个动态生成控件数组示例好吗???
[email protected]
谢谢!
你还要设置它的参数,才能正确使用
procedure TForm1.MSComm1Comm(Sender: TObject);我用得太久,具体说不出!!
2.MSCOMM 在 VB 里已有。或下载一个具有 COM 编程的 VB 程序就有。
3.我已设置好了且能发送。
begin
if Mscomm1.CommEvent = 2 then
Memo1.Lines.Add(inttostr(MsComm1.InputLen)+', '+ MSComm1.Input);
end;
(1)ComEvSend:值为1,发送缓冲区的内容少于SThreshold指定的值。
(2)ComEvReceive:值为2,接收缓冲区内字符数达到RThreshold指定的值。
(3)ComEvFrame:值为1004,硬件检测到帧错误。
(4)ComEvRxOver:值为1008,接收缓冲区溢出。
(5)ComEvTxFull:值为1010,发送缓冲区溢出。
(6)ComEvRxParity:值为1009,奇偶校验错误。
(7)ComEvEOF:值为7,接收数据中出现文件尾(ASCII码为26)字符。
1、改用了 COM 口的红外线,数据接收到了。但主板上红外口的红外线依然不行。
2、SPCOMM 接收到的数据我用下面的代码: var
i : integer;
str_mid : Ansistring;
TmpArray : array [0..1024] of byte; begin str_mid := ''; move ( buffer^, pchar((@TmpArray)^), bufferlngth+2 ); for i:=0 to bufferlength -1 do begin
// str_mid := str_mid + inttohex( TmpArray[i], 2);
// str_mid := inttohex( TmpArray[i], 2) + str_mid;
end; {for} ShowMessage (str_mid); end; 数据是接收到了,但: SPCOMM 的数据是这样处理的吗?需要高位与低位调换吗?听说SPCOMM 要从高读起。