delphi7中关于Spcomm用法请教高手?老提示这行有问题:move(buffer^,pchar(@rbuf^),bufferlength);
unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,F...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SPComm, Buttons;
type
TFCOMM = class(TForm)
Comm1: TComm;
Memo1: TMemo;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FCOMM: TFCOMM;
viewstring:string;
i:integer;
rbuf,sbuf:array[0..15] of byte;
implementation
{$R *.dfm}
//关闭串口
procedure TFCOMM.FormClose(Sender: TObject; var Action: TCloseAction);
begin
comm1.StopComm;
end;
//打开串口
procedure TFCOMM.FormShow(Sender: TObject);
begin
comm1.StartComm;
end;
//接收过程
procedure TFCOMM.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 TFCOMM.BitBtn2Click(Sender: TObject);
begin
close;
end;
end.
把move(buffer^,pchar(@rbuf^),bufferlength);
改成move(buffer^,pchar(@rbuf[0])^,bufferlength);
还是不行,跪求高手了。。。 展开
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SPComm, Buttons;
type
TFCOMM = class(TForm)
Comm1: TComm;
Memo1: TMemo;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FCOMM: TFCOMM;
viewstring:string;
i:integer;
rbuf,sbuf:array[0..15] of byte;
implementation
{$R *.dfm}
//关闭串口
procedure TFCOMM.FormClose(Sender: TObject; var Action: TCloseAction);
begin
comm1.StopComm;
end;
//打开串口
procedure TFCOMM.FormShow(Sender: TObject);
begin
comm1.StartComm;
end;
//接收过程
procedure TFCOMM.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 TFCOMM.BitBtn2Click(Sender: TObject);
begin
close;
end;
end.
把move(buffer^,pchar(@rbuf^),bufferlength);
改成move(buffer^,pchar(@rbuf[0])^,bufferlength);
还是不行,跪求高手了。。。 展开
2个回答
展开全部
move(buffer^,pchar(@rbuf^),bufferlength);
改成
move(buffer^,pchar(@rbuf[0])^,bufferlength);
试下
改成
move(buffer^,pchar(@rbuf[0])^,bufferlength);
试下
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
启帆信息
2024-11-19 广告
2024-11-19 广告
启帆信息是英伟达中国区代理商,原厂授权代理,提供全面的软件技术解决方案以及NVIDIA以太网产品、交换机等产品,欢迎前来咨询!...
点击进入详情页
本回答由启帆信息提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询