用SPCOMM打开COM10串口

MrGun 2002-10-08 10:32:12
由于SPCOMM只能打开COM9以下的串口,不能打开COM10后的串口;而用MSCOM能打开COM10,而本人不想较大改变程序,有哪位大虾能帮忙,非常感谢!最好能提供SPCOMM的升级版,目前本人的版本位2.5
...全文
55 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
使用示例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, SPComm, TeEngine, Series, ExtCtrls, TeeProcs, Chart; type TForm1 = class(TForm) Comm1: TComm; ComboBox1: TComboBox; ComboBox2: TComboBox; ComboBox3: TComboBox; ComboBox4: TComboBox; ComboBox5: TComboBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Button1: TButton; Memo1: TMemo; procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Viewstring:string; i:integer; rbuf,sbuf:array[1..6] of byte; implementation {$R *.dfm} procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word); var i:integer; begin viewstring:=' '; move(buffer^,pchar(@rbuf)^,bufferlength); for i:=1 to bufferlength do viewstring:=viewstring+inttohex(rbuf[i],2)+' '; viewstring:='接受'+viewstring; memo1.lines.add(viewstring); memo1.lines.add(' '); end; procedure TForm1.Button1Click(Sender: TObject); begin //判断按键的状态可以便面打开串口出错时,要按两次按键 if Button1.Caption = '打开串口' then begin // 串口初始化 //EnumComPorts(ComboBox1.Items);//得到串口列表 Comm1.CommName := ComboBox1.Text; Comm1.BaudRate := StrToInt(ComboBox2.Text); Comm1.Parity := None; //ComboBox3.Text Comm1.ByteSize := _8; //ComboBox4.Text Comm1.StopBits := _1; //ComboBox5.Text //########################################### Comm1.StartComm;//打开串口 Button1.Caption := '关闭串口'; ComboBox1.Enabled := false; ComboBox2.Enabled := false; ComboBox3.Enabled := false; ComboBox4.Enabled := false; ComboBox5.Enabled := false; //btnSend.Enabled := true; //ImageOff.Visible := false; //ImageOn.Visible := true; end else begin //############################################## Comm1.StopComm; // 关闭串口 Button1.Caption := '打开串口'; ComboBox1.Enabled := true; ComboBox2.Enabled := true; ComboBox3.Enabled := true; ComboBox4.Enabled := true; ComboBox5.Enabled := true; //btnSend.Enabled := false; //ImageOn.Visible := false; //ImageOff.Visible := true; end; end; end.

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧