这是我调用dlls的程序
unit dllprj;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function init:integer
external 'h:/工作目录/dllspcom/formprj.dll';
function entry:integer
external 'h:/工作目录/dllspcom/formprj.dll';
function readtrack(track :integer;info
char):string
external 'h:/工作目录/dllspcom/formprj.dll';
function getstr
char
external 'h:/工作目录/dllspcom/formprj.dll';
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
init();
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
entry();
end;
procedure TForm1.Button3Click(Sender: TObject);
var
info
char;
tmp:string;
begin
tmp:=readtrack(0,info);
info:=getstr();
showmessage(info);
end;
我发现一个问题,我在DLLS中使用了一个SPCOM的控件,当我运行BUTTON3时,先执行READTRACK()
然后执行GETSTR(),再执行showmessage(),这时,COM端口的信息才有返回。why????
按道理,我执行readtrack()时,信息已经发送端口,端口应该马上会有响应的。为什么一定
要等别的执行完才有响应。