L
lzmling
Unregistered / Unconfirmed
GUEST, unregistred user!
我在form中使用spcomm,接收数据正常,如:
我在onreceivedata事件中将返回值赋予rbuf数组,第一次发送数据就能正常返回为rbuf[1]=49
我在dll中使用spcomm,接收数据就不正常了,如:
我在dll中定义一个类TMyClass,
type
TMyClass = Class (TObject)
jmComm : TComm;
private
procedure ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word);
public
constructor Create;
destructor Destroy; override;
procedure startcomm(comname:shortstring);
procedure stopcomm(comname:shortstring);
function write(i:integer):boolean;
end;
procedure TMyClass.ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
begin
move(buffer^,pchar(@rbuf)^,bufferlength);
end;
只有在第二次发送数据时才能得到返回值rbuf[1]=49
为什么?
我在onreceivedata事件中将返回值赋予rbuf数组,第一次发送数据就能正常返回为rbuf[1]=49
我在dll中使用spcomm,接收数据就不正常了,如:
我在dll中定义一个类TMyClass,
type
TMyClass = Class (TObject)
jmComm : TComm;
private
procedure ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word);
public
constructor Create;
destructor Destroy; override;
procedure startcomm(comname:shortstring);
procedure stopcomm(comname:shortstring);
function write(i:integer):boolean;
end;
procedure TMyClass.ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
begin
move(buffer^,pchar(@rbuf)^,bufferlength);
end;
只有在第二次发送数据时才能得到返回值rbuf[1]=49
为什么?