程序如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SPComm;
type
TForm1 = class(TForm)
Comm1: TComm;
Memo1: TMemo;
procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
tmpArray:Byte;
pStr:PChar;
begin
pStr:=Buffer;
tmpArray:=Byte(PSTR^);
Memo1.Lines.Add(IntToHEX(Ord(tmpArray),2));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Comm1.StartComm;
end;
end.
这个是从一个例子中简化后的程序,简化后在原工程里可以运行,但是复制到新工程里就不能运行(但没有语法错误),表现为:memo1中无显示
高手给帮帮忙吧
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SPComm;
type
TForm1 = class(TForm)
Comm1: TComm;
Memo1: TMemo;
procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
tmpArray:Byte;
pStr:PChar;
begin
pStr:=Buffer;
tmpArray:=Byte(PSTR^);
Memo1.Lines.Add(IntToHEX(Ord(tmpArray),2));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Comm1.StartComm;
end;
end.
这个是从一个例子中简化后的程序,简化后在原工程里可以运行,但是复制到新工程里就不能运行(但没有语法错误),表现为:memo1中无显示
高手给帮帮忙吧
